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


PHP Carbon::today方法代码示例

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


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

示例1: schedule

 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule $schedule
  *
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     $schedule->command('inspire')->hourly();
     // 进入维护模式
     $schedule->command('down')->evenInMaintenanceMode()->dailyAt('23:00');
     //->when(function () {return true;});//
     // 更新用户等级
     $schedule->call(function () {
         $registrations = Registration::where('state', 0)->where(function ($query) {
             $query->where('registration_date', Carbon::yesterday()->toDateString());
         })->get();
         foreach ($registrations as $registration) {
             $user = $registration->user;
             $user->credit_level -= 1;
             $user->save();
         }
     })->evenInMaintenanceMode()->daily();
     //
     // 重置rest_num
     $schedule->call(function () {
         $doctor_schedules = DocSchedule::where('state', 0)->where(function ($query) {
             $week = [1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday', 7 => 'sunday'];
             $query->where('doctoring_date', $week[Carbon::today()->dayOfWeek]);
         })->get();
         foreach ($doctor_schedules as $doctor_schedule) {
             $doctor_schedule->rest_num = $doctor_schedule->total_num;
             $doctor_schedule->save();
         }
     })->evenInMaintenanceMode()->dailyAt('3:00');
     //
     // 离开维护模式
     $schedule->command('up')->evenInMaintenanceMode()->dailyAt('7:00');
     //
 }
开发者ID:Beyond-Game,项目名称:Raffaello,代码行数:41,代码来源:Kernel.php

示例2: it_checks_the_fixed_budget_attributes_are_correct_when_expense_is_on_same_day_as_starting_date

 /**
  * @test
  */
 public function it_checks_the_fixed_budget_attributes_are_correct_when_expense_is_on_same_day_as_starting_date()
 {
     $this->logInUser();
     //Create expense and income transactions with budget id of 2
     $this->createTransactionsOnStartingDate();
     $response = $this->apiCall('GET', 'api/budgets?fixed=true&includeExtra=true');
     $content = json_decode($response->getContent(), true);
     $budget = $content[0];
     $this->checkBudgetKeysExist($budget, true);
     // Check if the values are correct according to our seeders!!
     $this->assertEquals("http://localhost/api/budgets/2", $budget['path']);
     $this->assertEquals("business", $budget['name']);
     $this->assertEquals(100, $budget['amount']);
     $this->assertEquals(null, $budget['calculatedAmount']);
     $this->assertEquals('fixed', $budget['type']);
     $this->assertEquals(Carbon::today()->subMonths(8)->format('d/m/y'), $budget['formattedStartingDate']);
     $this->assertEquals(-270, $budget['spent']);
     $this->assertEquals(305, $budget['received']);
     $this->assertEquals(-240, $budget['spentOnOrAfterStartingDate']);
     $this->assertEquals(-30, $budget['spentBeforeStartingDate']);
     $this->assertEquals(205, $budget['receivedOnOrAfterStartingDate']);
     $this->assertEquals(9, $budget['cumulativeMonthNumber']);
     $this->assertEquals(900, $budget['cumulative']);
     $this->assertEquals(865, $budget['remaining']);
     $this->assertEquals(8, $budget['transactionsCount']);
     $this->assertResponseOk();
 }
开发者ID:JennySwift,项目名称:budget,代码行数:30,代码来源:FixedBudgetsIndexTest.php

示例3: search

 public function search(Request $request)
 {
     $rfc = $request->rfc;
     $tipo = $request->tipo_id;
     $today = Carbon::today();
     $today = $today->year . '-' . $today->month . '-' . $today->day;
     $paciente = Paciente::where('rfc', '=', $rfc)->where('tipo_id', '=', $tipo)->first();
     $tipo = Tipo::find($tipo);
     if (isset($paciente)) {
         if ($paciente->count() > 1) {
             $citas = Cita::orderBy('fecha', 'desc')->where('paciente_id', '=', $paciente->id)->take(5)->get();
             $citas->each(function ($citas) {
                 $citas->paciente->tipo;
                 $citas->medico->especialidad;
                 $citas->fecha = fecha_dmy($citas->fecha);
             });
             if ($citas->count() >= 1) {
                 return Response::json($citas, 200);
             } else {
                 $response = array('error' => 'true');
                 return Response::json('No se encontro citas con paciente RFC: ' . $rfc . ' - ' . $tipo->code, 500);
             }
         }
     } else {
         $response = array('error' => 'true');
         return Response::json('No se encontro Paciente con RFC: ' . $rfc . ' - ' . $tipo->code, 500);
     }
 }
开发者ID:rikardote,项目名称:agenda,代码行数:28,代码来源:BitacoraController.php

示例4: index

 /**
  * Display a listing of the resource.
  *
  * @param  string $customerId
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function index($customerId)
 {
     //TODO Create dynamic values
     $findDataRequest = array('creation[lte]' => Carbon::today()->addDay(1)->toDateString(), 'offset' => 0, 'limit' => 100);
     try {
         $openpayReference = OpenpayReferenceModel::where('user_id', $customerId)->first();
         if ($openpayReference == null) {
             return response()->json(array("response" => "error", "class" => "CustomerControllerError", "error" => array("code" => 101, "message" => "Customer doesn't exist")));
         }
         $customer = $this->openpay->customers->get($openpayReference->openpay_id);
         $cardList = $customer->cards->getList($findDataRequest);
         $data = array();
         //TODO Create dynamic values
         foreach ($cardList as $card) {
             $cardData = array();
             $cardData["card_number"] = $card->card_number;
             $cardData["id"] = $card->id;
             $cardData["brand"] = $card->brand;
             array_push($data, $cardData);
         }
         return response()->json(array("response" => "result", "result" => $data));
     } catch (\OpenpayApiError $e) {
         return response()->json(array("response" => "error", "class" => get_class($e), "error" => array("code" => $e->getErrorCode(), "message" => $e->getMessage(), "http_code" => $e->getHttpCode(), "category" => $e->getCategory())));
     } catch (\Exception $e) {
         return response()->json(array("response" => "error", "class" => get_class($e), "error" => array("code" => $e->getCode(), "message" => $e->getMessage())));
     }
 }
开发者ID:gozozo,项目名称:openpay-server,代码行数:34,代码来源:CustomerCardController.php

示例5: showUM

 public function showUM()
 {
     $tgl = Carbon::today();
     $thn = $tgl->year . $tgl->year + 1;
     $tagihans = TagihanPendaftar::where('ThnAkademik', $thn)->get();
     return view('tagihan.um', ['tagihans' => $tagihans]);
 }
开发者ID:blegoh,项目名称:Sikeu,代码行数:7,代码来源:TagihanController.php

示例6: index

 /**
  * Show the application dashboard.
  *
  * @return Response
  */
 public function index(ReferenceServiceInterface $referenceService)
 {
     $defaultPickupDate = Carbon::today()->addDay(3)->toDateString();
     $defaultReturnDate = Carbon::today()->addDay(5)->toDateString();
     $marquee = $referenceService->getMarquee();
     return view('sites.index', compact('defaultPickupDate', 'defaultReturnDate', 'marquee'));
 }
开发者ID:leonlianght,项目名称:AlwaysRejoice,代码行数:12,代码来源:SitesController.php

示例7: getKey

 /**
  * @return string
  */
 protected function getKey()
 {
     $today = Carbon::today();
     $month_prefix = $today->format('Ym');
     $customer_prefix = $this->customer->id;
     return 'ohmate-invitation-count-' . $customer_prefix . '-' . $month_prefix;
 }
开发者ID:whplay,项目名称:ohmate-shop,代码行数:10,代码来源:CustomerInvitationCounter.php

示例8: isCurrentlyAcceptingProposals

 /**
  * Whether conference is currently accepted talk proposals
  *
  * @return bool
  */
 public function isCurrentlyAcceptingProposals()
 {
     if (!$this->hasAnnouncedCallForProposals()) {
         return false;
     }
     return Carbon::today()->between($this->getAttribute('cfp_starts_at'), $this->getAttribute('cfp_ends_at'));
 }
开发者ID:edsonmichaque,项目名称:symposium,代码行数:12,代码来源:Conference.php

示例9: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $currentdate = Carbon::today();
     $affiliationActives = \App\Affiliation::orderBy('created_at', 'DEC')->where('finalization', '>=', $currentdate)->get();
     $affiliationInactives = \App\Affiliation::orderBy('created_at', 'DEC')->where('finalization', '<', $currentdate)->get();
     return view('affiliation.index')->with('affiliationActives', $affiliationActives)->with("affiliationInactives", $affiliationInactives);
 }
开发者ID:StivenSerna,项目名称:gym,代码行数:12,代码来源:AffiliationsController.php

示例10: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     //check if have entry for today
     //check if locked
     //if good kaliwali
     //else populate with zeroes
     //then lock
     if (Attendance::latest('att_date')->first()->att_date != Carbon::today()) {
         $currentDate = new Attendance();
         $currentDate->att_date = Carbon::today();
         $holiday = 0;
         if (Carbon::today()->format('l') == 'Friday' || Holiday::where('holidate', Carbon::today())->first() != null) {
             $holiday = 1;
         }
         $currentDate->holiday = $holiday;
         $currentDate->save();
     }
     foreach (Site::all() as $site) {
         foreach ($site->labor as $labor) {
             if ($labor->attendance()->where('att_date', Carbon::today()->format('Y-m-d G:i:s'))->first() != null) {
                 $labor->attendance()->where('att_date', Carbon::today()->format('Y-m-d G:i:s'))->first()->pivot->update(['locked' => 'true']);
             } else {
                 Attendance::latest('att_date')->first()->labor()->attach($labor->id);
                 $att = $labor->attendance()->where('att_date', Carbon::today()->format('Y-m-d G:i:s'))->first();
                 $att->pivot->locked = 'true';
                 $att->pivot->attended = $att->holiday == 1 ? 1 : 0;
                 $att->pivot->ot = 0;
                 $att->pivot->bot = 0;
                 $att->pivot->site = $labor->site->code;
                 $att->pivot->save();
             }
         }
     }
 }
开发者ID:botlax,项目名称:ttcattendance,代码行数:39,代码来源:FillMissed.php

示例11: store

 public function store(AdminPlacementCreateRequest $request)
 {
     $placement = Ad_Web::create($request->all());
     $placement->created_at = Carbon::today()->addDay(1);
     $ad = Ad::find($placement->ad_id);
     if ($ad->tipo == 'pequeño') {
         $placement->script = "<iframe src='" . url('imp/' . $placement->id . '-smwl') . "' scrolling='no' frameborder='0' width='300' height='250'></iframe>";
         $placement->save();
     } elseif ($ad->tipo == 'mediano') {
         $placement->script = "<iframe src='" . url('imp/' . $placement->id . '-lgrc') . "' scrolling='no' frameborder='0' width='728' height='90'></iframe>";
         $placement->save();
     } elseif ($ad->tipo == 'popup') {
         $placement->script = "<script src='" . url('imp/' . $placement->id . '-pobd') . "'></script>";
         $placement->save();
     } elseif ($ad->tipo == 'vertical') {
         $placement->script = "<iframe src='" . url('imp/' . $placement->id . '-vlty') . "' scrolling='no' frameborder='0' width='160' height='600'></iframe>";
         $placement->save();
     } else {
         $placement->script = "<iframe src='" . url('imp/' . $placement->id) . " scrolling='no' frameborder='0''></iframe>";
         $placement->save();
     }
     if ($placement->save()) {
         notify()->flash('Placement created correctly', 'success', ['timer' => 3000, 'text' => '']);
     } else {
         notify()->flash('There was a problem creating the placement', 'error', ['timer' => 3000, 'text' => '']);
     }
     return redirect()->to("admin/placement");
 }
开发者ID:JohanArmando,项目名称:MaxCorpMedia,代码行数:28,代码来源:FrontController.php

示例12: setStartDate

 /**
  * @param $startDate
  */
 protected function setStartDate(Carbon $startDate = null)
 {
     if (is_null($startDate)) {
         $startDate = Carbon::today();
     }
     $this->startDate = $startDate;
 }
开发者ID:ValentinGot,项目名称:trakt-api-wrapper,代码行数:10,代码来源:TimePeriod.php

示例13: ajaxRateInfo

 public function ajaxRateInfo(Request $request)
 {
     /*$rate_id = $request->rate_id;
       $rate = Rate::where('id', '=', $rate_id)->get();
       return Response::json($rate);*/
     $rate_id = $request->rate_id;
     $rate = Rate::where('id', '=', $rate_id)->firstOrFail();
     $price = number_format($rate->price, 2);
     if ($rate->period == 'day') {
         $expirationDate = Carbon::today()->addDays($rate->period_count)->format('F d\\, Y');
     } else {
         if ($rate->period == 'month') {
             $expirationDate = Carbon::today()->addMonths($rate->period_count)->subDay()->format('F d\\, Y');
         } else {
             if ($rate->period == 'year') {
                 $expirationDate = Carbon::today()->addYears($rate->period_count)->subDay()->format('F d\\, Y');
             }
         }
     }
     /*if($rate_id == 2)
       {
           $expirationDate = Carbon::today()->addMonth()->format('F d\\, Y');      
       }
       else if($rate_id == 6)
       {
           $expirationDate = Carbon::today()->addYear()->subDay()->format('F d\\, Y');  
       }*/
     return Response::json(['price' => $price, 'expirationDate' => $expirationDate]);
 }
开发者ID:sephestrito,项目名称:learning-laravel-5,代码行数:29,代码来源:RatesController.php

示例14: store

 /**
  * Function for storing a new blog article.
  *
  * @param $request
  * @param ArticleRequest $request
  * @return Redirect
  */
 public function store(ArticleRequest $request)
 {
     if ($request->has('slug')) {
         $request['slug'] = str_slug($request['slug'], "_");
     } else {
         $request['slug'] = str_slug($request['title'], "_");
     }
     $today = Carbon::today()->format('Y') . '/' . Carbon::today()->format('M') . '/' . Carbon::today()->format('d');
     $uploadPath = base_path() . '/public/img/uploads/' . $today;
     $article = Article::create($request->all());
     // TODO: Refine into two seperate actions //
     if (!empty($request['cover-image']) || !empty($request['cover-image'])) {
         $SmallImageName = '/img/uploads/' . $today . '/' . $request['slug'] . '_sml' . '.' . $request->file('listing-image')->getClientOriginalExtension();
         $coverImageName = '/img/uploads/' . $today . '/' . $request['slug'] . '_cover' . '.' . $request->file('cover-image')->getClientOriginalExtension();
         $article['imgfull'] = $coverImageName;
         $article['imgsml'] = $SmallImageName;
     }
     $article['page_code'] = str_random(16);
     $article['author'] = Auth::user()->id;
     $article['category'] = $request['category'];
     // TODO:: Preform a check to see if this Category Exists //
     $article['published'] = Carbon::parse($request['published']);
     // TODO:: Add a time to publish field //
     $article->save();
     if (!empty($request['cover-image']) || !empty($request['cover-image'])) {
         $request->file('listing-image')->move($uploadPath, $SmallImageName);
         $request->file('cover-image')->move($uploadPath, $coverImageName);
     }
     return redirect('blog/' . $request->slug);
 }
开发者ID:JBird608,项目名称:JoeCurran_Codes,代码行数:37,代码来源:BlogController.php

示例15: it_checks_the_flex_budget_attributes_are_correct_when_including_the_extra_budget_attributes

 /**
  * @test
  */
 public function it_checks_the_flex_budget_attributes_are_correct_when_including_the_extra_budget_attributes()
 {
     $this->logInUser();
     $response = $this->apiCall('GET', 'api/budgets?flex=true&includeExtra=true');
     $content = json_decode($response->getContent(), true);
     //        dd($content);
     $budget = $content[0];
     //        dd($budget);
     $this->checkBudgetKeysExist($budget, true);
     // Check if the values are correct according to our seeders!!
     $this->assertEquals("http://localhost/api/budgets/4", $budget['path']);
     $this->assertEquals("busking", $budget['name']);
     $this->assertEquals(10, $budget['amount']);
     $this->assertEquals(20, $budget['calculatedAmount']);
     $this->assertEquals('flex', $budget['type']);
     $this->assertEquals(Carbon::today()->subMonths(8)->format('d/m/y'), $budget['formattedStartingDate']);
     $this->assertEquals(-35, $budget['spent']);
     $this->assertEquals(1500, $budget['received']);
     $this->assertEquals(-15, $budget['spentBeforeStartingDate']);
     $this->assertEquals(-20, $budget['spentOnOrAfterStartingDate']);
     $this->assertEquals(1000, $budget['receivedOnOrAfterStartingDate']);
     $this->assertEquals(9, $budget['cumulativeMonthNumber']);
     $this->assertEquals(null, $budget['cumulative']);
     $this->assertEquals(1000, $budget['remaining']);
     $this->assertEquals(6, $budget['transactionsCount']);
     $this->assertResponseOk();
 }
开发者ID:JennySwift,项目名称:budget,代码行数:30,代码来源:FlexBudgetTotalsTest.php


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