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


PHP Carbon::addDays方法代码示例

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


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

示例1: fromDateToYuleDate

 /**
  * Returns the yule party date for the given year
  *
  * @param Carbon $date
  * @return Carbon
  */
 private function fromDateToYuleDate(Carbon $date)
 {
     while ($date->dayOfWeek != Carbon::FRIDAY) {
         $date->addDay();
     }
     $date->addDays(8);
     return $date;
 }
开发者ID:PuppetmasterDK,项目名称:yule-party,代码行数:14,代码来源:YuleDate.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     try {
         DB::beginTransaction();
         $validator = Validator::make(Input::all(), array('name' => 'required', 'email' => 'required|email', 'password' => 'required'));
         if ($validator->fails()) {
             return Response::json($validator->messages(), 400);
         }
         $name = Input::get('name');
         $password = Input::get('password');
         $email = Input::get('email');
         $user = User::findUserByEmail($email);
         if (isset($user)) {
             return Response::json(array('error' => Config::get('constants.STATUS_CODES.USER.USER_EXISTS'), 'error_message' => 'User already exists'), 500);
         }
         $user = User::create(array('name' => $name, 'uid' => 'usr_' . str_random(16), 'english_name' => $name, 'email' => $email, 'password' => $password, 'raw_password' => $password, 'activated' => Config::get('auth.need_activated') ? false : true));
         if (Config::get('auth.need_activated')) {
             $activateTokens = $user->validActivationCodes()->get();
             if (count($activateTokens) > 1) {
                 throw new Exception('More than one activated token found, user: ' . $this->id);
             }
             $activateToken = count($activateTokens) == 0 ? null : $tokens[0];
             if (isset($activateToken)) {
                 $user->activation_code = $activateToken->id;
                 $user->save();
             } else {
                 $expire_time = new Carbon();
                 $expire_time->addDays(Config::get('auth.activated_token_expired_in'));
                 \Log::info($expire_time->timestamp);
                 $token = Util::geneateRandom();
                 $userActivationCode = new UserActivationCode();
                 $userActivationCode->token = $token;
                 $userActivationCode->expire_time = $expire_time->timestamp;
                 $user->validActivationCodes()->save($userActivationCode);
             }
         }
         $userRole = Role::where('name', 'user')->get()->first();
         $user->attachRole($userRole);
         if (Config::get('auth.need_activated')) {
             $this->mailer->welcomeButNeedActivate($user);
         } else {
             $this->mailer->welcome($user);
         }
         DB::commit();
         if (!Config::get('auth.need_activated')) {
             return Response::json(array('success_code' => Config::get('constants.STATUS_CODES.USER.OK'), 'data' => $user->toArray()));
         } else {
             return Response::json(array('error' => Config::get('constants.STATUS_CODES.USER.NEED_ACTIVATED'), 'error_message' => 'Successfully Registered, You need to activate then.', 'data' => $user->toArray()), 500);
         }
     } catch (Exception $e) {
         \Log::error($e);
         DB::rollback();
         return Response::json(array('error' => true, 'error_message' => $e->getMessage()), 500);
     }
 }
开发者ID:rhalff,项目名称:vdragon-api,代码行数:60,代码来源:UserController.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(AffiliationCreateRequest $request)
 {
     //dd($request);
     /*"_token" => "8s9rQffPRk7lOCtbGidK1Wzvp4fmMQ00GLTvNFQv"
           "member_id" => "1"
           "membership_id" => "1"
           "initiation" => "2016-02-11"
           "type" => "payment"
     
               0 => "initiation"
         1 => "finalization"
         2 => "price"
         3 => "payout"
         4 => "type"
         5 => "active"
         6 => "member_id"
         7 => "membership_id"*/
     $membership = Membership::find($request->membership_id);
     $affiliation = new Affiliation($request->all());
     $payment = new Payment();
     $end = new Carbon($request->initiation);
     if ($membership->month > 0) {
         $end->addMonths($membership->month);
     }
     if ($membership->day > 0) {
         $end->addDays($membership->day - 1);
     }
     $payment->member_id = $request->member_id;
     $affiliation->finalization = $end;
     $affiliation->price = $membership->price;
     if ($request->type == "credit") {
         $payment->amount = $request->payout;
         $payment->type = "payout";
     } else {
         $payment->amount = $membership->price;
         $payment->type = "payment";
     }
     $affiliation->save();
     if ($payment->amount > 0) {
         $payment->save();
     }
     Flash::success("¡Se ha registrado la afiliacion del miembro de manera exitosa!");
     return redirect()->route('admin.member.show', [$request->member_id, '#membership-member']);
 }
开发者ID:StivenSerna,项目名称:gym,代码行数:50,代码来源:AffiliationsController.php

示例4: getChartData

 public function getChartData()
 {
     $minDate = date('Y-m-d', strtotime('-3 months'));
     $maxDate = date('Y-m-d', strtotime('+1 day'));
     $data = (new QueueEntity())->select(['status', 'week' => 'WEEKOFYEAR(created_at)', 'year' => 'YEAR(created_at)', 'count' => 'COUNT(id)'])->groupBy('WEEKOFYEAR(created_at), YEAR(year), status')->where('created_at', $minDate, '>')->all();
     $date = new Carbon($minDate);
     $times = [];
     /**
      * Prepare times.
      */
     while ($maxDate > $date) {
         $times[$date->year . '-' . $date->weekOfYear] = [];
         $date->addDays(7);
     }
     $statuses = [];
     $data->each(function (QueueRecord $queue) use(&$times, &$statuses) {
         $times[$queue->year . '-' . $queue->week][$queue->status] = $queue->count;
         $statuses[$queue->status][$queue->year . '-' . $queue->week] = $queue->count;
     });
     $chart = ['labels' => array_keys($times), 'datasets' => []];
     $colors = ['finished' => 'rgba(0, 255, 0, 0.33)', 'failed_permanently' => 'rgba(255, 0, 0, 0.33)', 'created' => 'rgba(0, 0, 255, 0.33)', 'skipped_unique' => 'rgba(100, 100, 100, 0.33)', 'total' => 'rgba(50, 50, 50, 0.33)'];
     foreach ($statuses as $status => $statusTimes) {
         $dataset = ['label' => $status, 'data' => [], 'borderColor' => $colors[$status], 'backgroundColor' => 'transparent', 'borderWidth' => 1];
         foreach ($times as $time => $timeStatuses) {
             $dataset['data'][] = $statusTimes[$time] ?? 0;
         }
         $chart['datasets'][] = $dataset;
     }
     $dataset = ['label' => 'total', 'data' => [], 'borderColor' => $colors['total'], 'backgroundColor' => 'transparent', 'borderWidth' => 1];
     foreach ($times as $time => $statuses) {
         $total = 0;
         foreach ($statuses as $status) {
             $total += $status;
         }
         $dataset['data'][] = $total;
     }
     $chart['datasets'][] = $dataset;
     return $chart;
 }
开发者ID:pckg,项目名称:queue,代码行数:39,代码来源:Queue.php

示例5: calculateObservedDay

 protected function calculateObservedDay(Carbon $date)
 {
     if ($date->dayOfWeek === Carbon::SUNDAY) {
         return $date->addDays(1);
     } elseif ($date->dayOfWeek === Carbon::SATURDAY) {
         return $date->subDays(1);
     }
     return $date;
 }
开发者ID:jyggen,项目名称:pingu,代码行数:9,代码来源:HolidayPlugin.php

示例6: scopeFuture

 /**
  * Restricts to dates after $days days from today.
  * @param  object $query
  * @param  integer $days
  * @return object $query
  */
 public function scopeFuture($query, $days)
 {
     $date = new Carbon();
     $date->addDays($days);
     return $query->where('date', '<=', $date);
 }
开发者ID:ardani,项目名称:MyCalendar,代码行数:12,代码来源:Event.php

示例7: show

 /**
  * Display single items of a plan with options to move to the next or previous item on this plan
  *
  * This is used for the presentation views (lyrics, chords, sheetmusic or leader)
  *
  * @param  int     $id      item id
  * @param  string  $present (optional) chords (default), sheetmusic or present (for overhead presentations) or leader for the Leader's Event Script
  *
  * @return \Illuminate\Http\Response
  */
 public function show($id, $present = null)
 {
     $item = Item::find($id);
     if ($item) {
         $events = [];
         // is this the Announcements Slide?
         if ($item->key == 'announcements') {
             $today = new Carbon($item->plan->date);
             $oneWeek = $today->addDays(7);
             // get ALL future events incl today
             $events = Plan::with(['type', 'leader', 'teacher'])->whereDate('date', '>', $item->plan->date->subDay())->whereDate('date', '<', $oneWeek)->where('id', '!=', $item->plan_id)->orderBy('date', 'asc')->get();
         }
         // default presentation type is to show chords
         if (!$present) {
             $present = 'chords';
         }
         return view('cspot.' . $present, ['item' => $item, 'events' => $events, 'versionsEnum' => json_decode(env('BIBLE_VERSIONS')), 'items' => $item->plan->items->sortBy('seq_no')->all(), 'type' => $present, 'bibleTexts' => getBibleTexts($item->comment)]);
     }
     flashError('Error! Item with ID "' . $id . '" was not found! (F:show)');
     return \Redirect::route('home');
 }
开发者ID:matthiku,项目名称:cSpot,代码行数:31,代码来源:ItemController.php

示例8: getBeginningAndEndingWeekDates

 /**
  * @param $dateSelected
  *
  * @return array
  */
 protected function getBeginningAndEndingWeekDates($dateSelected)
 {
     $dateSelected = $this->deriveDateSelected($dateSelected);
     $bwDate = new Carbon($dateSelected);
     if ($bwDate->dayOfWeek == 0) {
         $ewDate = new Carbon($bwDate);
         $iso_beginning_dow_date = new Carbon($bwDate);
         $ewDate->addDays(6);
     } else {
         $bwDate->startOfWeek();
         // iso standard; Monday is the start of week.
         $iso_beginning_dow_date = new Carbon($bwDate);
         $bwDate->subDay();
         // adjust to Sunday as this is our current offset.
         $ewDate = new Carbon($bwDate);
         $ewDate->addDays(6);
     }
     return [$bwDate, $ewDate, $iso_beginning_dow_date];
 }
开发者ID:RichJones22,项目名称:TimeTrax,代码行数:24,代码来源:TimeCardController.php

示例9: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     $faker = \Faker\Factory::create();
     // create agents
     $agents_counter = 1;
     for ($a = 1; $a <= $this->agents_qty; $a++) {
         $agent_info = new \App\User();
         $agent_info->name = $faker->name;
         $agent_info->email = 'agent' . $agents_counter . $this->email_domain;
         $agent_info->ticketit_agent = 1;
         $agent_info->password = Hash::make($this->default_agent_password);
         $agent_info->save();
         $agents[$agent_info->id] = $agent_info;
         $agents_counter++;
     }
     // create tickets statuses
     foreach ($this->statuses as $name => $color) {
         $status = \Kordy\Ticketit\Models\Status::create(['name' => $name, 'color' => $color]);
     }
     $counter = 0;
     // create tickets statuses
     foreach ($this->categories as $name => $color) {
         $category = \Kordy\Ticketit\Models\Category::create(['name' => $name, 'color' => $color]);
         $agent = array_rand($agents, $this->agents_per_category);
         $category->agents()->attach($agent);
         $counter++;
     }
     // create tickets statuses
     foreach ($this->priorities as $name => $color) {
         $priority = \Kordy\Ticketit\Models\Priority::create(['name' => $name, 'color' => $color]);
     }
     $categories_qty = \Kordy\Ticketit\Models\Category::count();
     $priorities_qty = \Kordy\Ticketit\Models\Priority::count();
     $statuses_qty = \Kordy\Ticketit\Models\Status::count();
     // create users
     $users_counter = 1;
     for ($u = 1; $u <= $this->users_qty; $u++) {
         $user_info = new \App\User();
         $user_info->name = $faker->name;
         $user_info->email = 'user' . $users_counter . $this->email_domain;
         $user_info->ticketit_agent = 0;
         $user_info->password = Hash::make($this->default_user_password);
         $user_info->save();
         $users_counter++;
         $tickets_qty = rand($this->tickets_per_user_min, $this->tickets_per_user_max);
         for ($t = 1; $t <= $tickets_qty; $t++) {
             $rand_category = rand(1, $categories_qty);
             $priority_id = rand(1, $priorities_qty);
             do {
                 $rand_status = rand(1, $statuses_qty);
             } while ($rand_status == $this->default_closed_status_id);
             $category = \Kordy\Ticketit\Models\Category::find($rand_category);
             $agents = $category->agents()->lists('name', 'id')->toArray();
             $agent_id = array_rand($agents);
             $random_create = rand(1, $this->tickets_date_period);
             $random_complete = rand($this->tickets_min_close_period, $this->tickets_max_close_period);
             $ticket = new \Kordy\Ticketit\Models\Ticket();
             $ticket->subject = $faker->text(50);
             $ticket->content = $faker->paragraph($nbSentences = 10);
             $ticket->status_id = $rand_status;
             $ticket->priority_id = $priority_id;
             $ticket->user_id = $user_info->id;
             $ticket->agent_id = $agent_id;
             $ticket->category_id = $rand_category;
             $ticket->created_at = \Carbon\Carbon::now()->subDays($random_create);
             $ticket->updated_at = \Carbon\Carbon::now()->subDays($random_create);
             $completed_at = new Carbon($ticket->created_at);
             if (!$completed_at->addDays($random_complete)->gt(\Carbon\Carbon::now())) {
                 $ticket->completed_at = $completed_at;
                 $ticket->updated_at = $completed_at;
                 $ticket->status_id = $this->default_closed_status_id;
             }
             $ticket->save();
             $comments_qty = rand($this->comments_per_ticket_min, $this->comments_per_ticket_max);
             for ($c = 1; $c <= $comments_qty; $c++) {
                 if (is_null($ticket->completed_at)) {
                     $random_comment_date = $faker->dateTimeBetween('-' . $random_create . ' days', 'now');
                 } else {
                     $random_comment_date = $faker->dateTimeBetween('-' . $random_create . ' days', '-' . ($random_create - $random_complete) . ' days');
                 }
                 $comment = new \Kordy\Ticketit\Models\Comment();
                 $comment->ticket_id = $ticket->id;
                 $comment->content = $faker->paragraph($nbSentences = 10);
                 if ($c % 2 == 0) {
                     $comment->user_id = $ticket->user_id;
                 } else {
                     $comment->user_id = $ticket->agent_id;
                 }
                 $comment->created_at = $random_comment_date;
                 $comment->updated_at = $random_comment_date;
                 $comment->save();
             }
             $last_comment = $ticket->Comments->sortByDesc('created_at')->first();
             $ticket->updated_at = $last_comment['created_at'];
//.........这里部分代码省略.........
开发者ID:darkflamed,项目名称:ticketit,代码行数:101,代码来源:TicketitTableSeeder.php

示例10: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $today = Carbon::today();
     $nextMonth = Carbon::today()->addMonth();
     $monday = new Carbon('next monday');
     $sunday = new Carbon('next monday');
     $sunday->addDays(6);
     echo $sunday;
     $planningen = Planning::where('first_day', '>', $today)->get();
     var_dump($planningen);
     while ($monday < $nextMonth) {
         $not_exists = true;
         foreach ($planningen as $planning) {
             if ($monday >= $planning->first_day && $monday <= $planning->last_day) {
                 $not_exists = false;
             }
         }
         if ($not_exists) {
             $newPlanning = new Planning();
             $newPlanning->first_day = $monday;
             $newPlanning->last_day = $sunday;
             $newPlanning->save();
         }
         $monday->addWeek();
         $sunday->addWeek();
     }
 }
开发者ID:jimpeeters,项目名称:ProjectInternetOfThings,代码行数:32,代码来源:createPlanning.php

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