小编Ari*_*jay的帖子

Yii2 REST + Angular Cross Domain CORS

我开发了Angular和Yii2 REST服务.在跨域有问题.下面添加我的angular&Yii2 REST代码.

AngularJs:(像' http://organization1.example.com ', ' http://organization2.example.com ',....)

$http.defaults.useXDomain = true;
$http.defaults.withCredentials = true;
$http.defaults.headers.common['Authorization'] = 'Bearer ' + MYTOKEN
Run Code Online (Sandbox Code Playgroud)

我来自Angular Controller的请求:

apiURL = 'http://api.example.com';
$http.get(apiURL + '/roles')
     .success(function (roles) { })
     .error(function () { });
Run Code Online (Sandbox Code Playgroud)

Yii2 .htaccess :( REST网址如' http://api.example.com ')

Header always set Access-Control-Allow-Origin: "*"
Header always set Access-Control-Allow-Credentials: true
Header always set Access-Control-Allow-Methods "POST, GET, PUT, DELETE, OPTIONS"
Header always set Access-Control-Allow-Headers "Authorization,X-Requested-With, content-type"
Run Code Online (Sandbox Code Playgroud)

Yii2我的行为:

public function behaviors() {
    $behaviors = parent::behaviors();
    $behaviors['corsFilter'] = [
        'class' …
Run Code Online (Sandbox Code Playgroud)

rest yii-components angularjs yii2 yii2-advanced-app

6
推荐指数
2
解决办法
7349
查看次数

PHP使用DatePeriod创建具有中断时间的时间段

我想创建包含开始,结束时间和休息时间的时隙.

public function getServiceScheduleSlots($duration,$break, $stTime,$enTime)
{
    $start = new DateTime($stTime);
    $end = new DateTime($enTime);
    $interval = new DateInterval("PT" . $duration. "M");
    $period = new DatePeriod($start, $duration, $end);

    foreach ($period as $dt) {
        $periods[] = $dt->format('H:iA');
    }
    return $periods;
}
Run Code Online (Sandbox Code Playgroud)

例如,
我的服务开始时间为上午10:00,结束时间中午12:00.
条件: 每个服务时间30分钟15分钟休息.

上面的方法返回如,

  • 上午10:00 - 上午10:30
  • 上午10:30 - 上午11:00
  • 上午11:00 - 上午11:30
  • 上午11:30 - 中午12:00

预期结果为,

  • 上午10:00 - 上午10:30
  • 上午10:45 - 上午11:15
  • 上午11:30 - 中午12:00

我想在每个时段开始时添加休息时间.

提前致谢.

php datetime php-5.3

4
推荐指数
1
解决办法
1992
查看次数