当前位置: 首页>>代码示例>>PHP>>正文


PHP Carbon::addMinutes方法代码示例

本文整理汇总了PHP中Carbon\Carbon::addMinutes方法的典型用法代码示例。如果您正苦于以下问题:PHP Carbon::addMinutes方法的具体用法?PHP Carbon::addMinutes怎么用?PHP Carbon::addMinutes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Carbon\Carbon的用法示例。


在下文中一共展示了Carbon::addMinutes方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postStartCountdown

 /**
  * Admin: Start stream countdown.
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postStartCountdown($stream)
 {
     $counter = AnnouncementCounter::getByStream($stream);
     $name = Input::get('name');
     $endTime = new Carbon();
     $endTime->addMinutes(10);
     $counter->ends_at = $endTime;
     $counter->save();
     $this->broadcast(array('stream' => $stream, 'type' => 'notify', 'text' => $name, 'expires' => $endTime->timestamp));
     Flash::success('Отчет завершится в ' . $endTime->format('H:i:s'));
 }
开发者ID:fencer-md,项目名称:stoticlle,代码行数:15,代码来源:AnnouncementsController.php

示例2: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     for ($i = 0; $i < $this->usersCount; $i++) {
         $date = new Carbon();
         $date->subMinute(rand(1, 60 * 24 * 30));
         $username = $i === 0 ? 'martiros.aghajanyan' : strtolower($this->faker->userName) . rand(100000, 200000);
         $user = User::create(['username' => $username, 'email' => $username . '@gmail.com', 'password' => Hash::make('test123'), 'show_status' => User::STATUS_ACTIVE, 'created_at' => $date, 'updated_at' => $date]);
         $ip = $this->faker->ipv4;
         $date->addMinutes(rand(1, 60));
         $user->userInfo()->create(['confirmation_code' => rand(100000, 999999), 'confirmation_ip' => $ip, 'reg_ip' => $ip, 'confirmation_date' => $date]);
     }
 }
开发者ID:practicegeniusci,项目名称:DemoApp,代码行数:18,代码来源:UserSeeder.php

示例3: store

 public function store()
 {
     $errors = false;
     /* @var $user \User */
     $user = User::where('email', '=', Input::get('email'))->first();
     // Check previous session for users.
     if ($user && $user->role == User::ROLE_USER) {
         if (!empty($user->session) && Session::getId() != $user->session && !$user->session_expires->isPast()) {
             $errors = true;
         }
     }
     if (!$errors) {
         $credentials = Input::only('email', 'password');
         $credentials['registration_status'] = 1;
         if (Auth::attempt($credentials)) {
             if (Auth::user()->role == "1") {
                 return Redirect::to('/user/admin/transactions/all');
             } else {
                 // Set user's session. Will expire in 5 min.
                 $user->session = Session::getId();
                 $sessionExpires = new Carbon();
                 $sessionExpires->addMinutes(5);
                 $user->session_expires = $sessionExpires;
                 $user->save();
                 // Redirect to user's profile when logged in first time.
                 if (!empty(Auth::user()->first_login)) {
                     return Redirect::to('/user/edit');
                 } else {
                     // Redirect to user's transactions.
                     return Redirect::to('/user/transactions');
                 }
             }
         }
     }
     Auth::logout();
     // TODO: Localize error message.
     return Redirect::to('/')->with('errorTitle', 'Login failed.')->with('error', 'Incorrect credentials. <a href="' . action('RemindersController@getRemind') . '">Forgot your password?</a>');
     // Message in popup.
 }
开发者ID:fencer-md,项目名称:stoticlle,代码行数:39,代码来源:SessionsController.php

示例4: storeSchedule

    public function storeSchedule()
    {
        $input['json'] = '{
						    "user": "3",
						    "event": "1",
						    "time_slots": [
						        {
						            "start": 1411239474,
						            "end": 1411539474,
						            "weighting": "5"
						        },
						        {
						            "start": 1411269474,
						            "end": 1411549474,
						            "weighting": "5"
						        }
						    ]
						}';
        $decoded = json_decode($input['json']);
        $user_id = $decoded->user;
        $occasion_id = $decoded->event;
        // Get the occasion tied to the user
        $occasion = User::find($user_id)->occasions->find($occasion_id);
        if ($occasion == null) {
            return null;
        }
        $time_slots = $decoded->time_slots;
        $insert = array();
        for ($i = 0; $i < count($time_slots); $i++) {
            $start = $time_slots[$i]->start;
            $ts_start = Carbon::createFromTimeStamp($start);
            $end = $time_slots[$i]->end;
            $ts_end = Carbon::createFromTimeStamp($end);
            $insert[] = array('start' => $ts_start->toDateTimeString(), 'end' => $ts_end->toDateTimeString(), 'weighting' => $time_slots[$i]->weighting, 'user_id' => $user_id, 'occasion_id' => $occasion_id);
        }
        //dd($insert);
        Timeslot::insert($insert);
        $occasion->pivot->complete = 1;
        $occasion->pivot->save();
        $num_incomplete_occasions = Occasion::find($occasion_id)->users()->wherePivot('complete', 0)->count();
        if ($num_incomplete_occasions != 0) {
            return $occasion;
        }
        // The events are done - push
        $occasion = Occasion::find($occasion_id);
        $host_start = new Carbon($occasion->start);
        $host_end = new Carbon($occasion->end);
        $diff = $host_start->diffInMinutes($host_end);
        $num_users = $occasion->users->count();
        $score = array();
        $score = array_fill(0, 10000, 0);
        //$score[0] = 'test';
        //$score = 0;
        $k = 0;
        $previous = new Carbon($occasion->start);
        // implement eager loading
        for ($i = 0; $i < $diff; $i += 15) {
            for ($j = 0; $j < $num_users; $j++) {
                $start = new Carbon($occasion->start);
                $start->addMinutes($i);
                $timeslot = Timeslot::where('user_id', '=', $j)->where('start', '<=', $previous->toDateTimeString())->where('end', '>=', $start->toDateTimeString())->first();
                if ($timeslot != null) {
                    //dd($timeslot);
                    //$score = array_add($score, $i, $timeslot->weighting);
                    $score[$i] += $timeslot->weighting;
                    //$score[$i] += $timeslot->weighting;
                    //$score[] = array($timeslot->weighting);
                    //$k++;
                    //var_dump($score);
                }
            }
            $previous = $start;
        }
        $score = array_filter($score);
        //dd($score);
        rsort($score);
        $top3 = array_reverse(array_slice($score, 0, 3));
        $users = Occasion::find($occasion_id)->users()->get();
        $data = array('temp');
        $users = $users->each(function ($user) use($data) {
            \Mail::send('emails.invite', $data, function ($message) use($user) {
                $message->to($user->email, $user->name)->subject('Your event has been scheduled!');
            });
            \Twilio::message($user->phone, 'An event has finished scheduling! Open up Calendr to learn more.');
        });
        $app_id = 'jVmr9Q4ItzKs2abze4T2mRvECJ8AxMwCKT5G8anC';
        $rest_key = 'hNv7GwawFKdvpyb6B6u8sLqlSQMW3YWWRQeKVll7';
        $master_key = 'wzwEOPsb5w45qWQQVJSCqTtL6yvD82Y90SiVDh4y';
        ParseClient::initialize($app_id, $rest_key, $master_key);
        $data = array("alert" => "An event has finished scheduling! Press here to learn more.");
        ParsePush::send(array("channels" => ["PHPFans"], "data" => $data));
        $query = ParseInstallation::query();
        $query->equalTo("design", "rad");
        ParsePush::send(array("where" => $query, "data" => $data));
        //	dd($score);
    }
开发者ID:seeARMS,项目名称:HackTheNorth_API,代码行数:96,代码来源:Algorithm.php

示例5: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $date = new Carbon();
     //Create 500 new data points
     factory(App\Models\BanchoStats::class, 500)->make()->each(function ($stat) use($date) {
         $stat->date = $date;
         $stat->save();
         //Increment the dates by 5 each time
         $date->addMinutes(5);
     });
 }
开发者ID:ameliaikeda,项目名称:osu-web,代码行数:16,代码来源:BanchoStatsSeeder.php

示例6: calculateNotBeforeTime

 /**
  *
  * @param Item $item
  * @param Carbon $notBeforeTime
  * @return Carbon
  */
 private function calculateNotBeforeTime(Item $item, Carbon $notBeforeTime)
 {
     switch ($item->recurring_unit) {
         case "minute":
             $notBeforeTime->addMinutes($item->recurring_frequency);
             break;
         case "hour":
             $notBeforeTime->addHours($item->recurring_frequency);
             break;
         case "day":
             $notBeforeTime->addDays($item->recurring_frequency);
             break;
         case "week":
             $notBeforeTime->addWeeks($item->recurring_frequency);
             break;
         case "month":
             $notBeforeTime->addMonths($item->recurring_frequency);
             break;
         case "year":
             $notBeforeTime->addYears($item->recurring_frequency);
             break;
     }
     return $notBeforeTime;
 }
开发者ID:JennySwift,项目名称:lists,代码行数:30,代码来源:ItemsRepository.php


注:本文中的Carbon\Carbon::addMinutes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。