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


PHP Carbon::create方法代码示例

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


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

示例1: post

 public function post()
 {
     if (Input::has('api_key') && Input::has('content')) {
         $api_key = Input::get('api_key');
         $content = Input::get('content');
         $settings = Settings::where('api_key', '=', $api_key)->first();
         $user_id = $settings->user_id;
         $default_networks = json_decode($settings->default_networks, true);
         $schedule = Carbon::now();
         if (Input::has('queue')) {
             $schedule_id = $settings->schedule_id;
             $interval = Schedule::find($schedule_id);
             if ($interval->rule == 'add') {
                 $schedule = $current_datetime->modify('+ ' . $interval->period);
             } else {
                 if ($interval->rule == 'random') {
                     $current_day = date('d');
                     $from_datetime = Carbon::now();
                     $to_datetime = $from_datetime->copy()->modify('+ ' . $interval->period);
                     $days_to_add = $from_datetime->diffInDays($to_datetime);
                     $day = mt_rand($current_day, $current_day + $days_to_add);
                     $hour = mt_rand(1, 23);
                     $minute = mt_rand(0, 59);
                     $second = mt_rand(0, 59);
                     //year, month and timezone is null
                     $schedule = Carbon::create(null, null, $day, $hour, $minute, $second, null);
                 }
             }
             if (empty($schedule)) {
                 $schedule = $current_datetime->addHours(1);
             }
         }
         if (!empty($default_networks)) {
             $post = new Post();
             $post->user_id = $user_id;
             $post->content = $content;
             $post->date_time = $schedule;
             $post->save();
             $post_id = $post->id;
             foreach ($default_networks as $network_id) {
                 $post_network = new PostNetwork();
                 $post_network->user_id = $user_id;
                 $post_network->post_id = $post_id;
                 $post_network->network_id = $network_id;
                 $post_network->status = 1;
                 $post_network->save();
             }
             Queue::later($schedule, 'SendPost@fire', array('post_id' => $post_id));
             $response_data = array('type' => 'success', 'text' => 'Your post was scheduled! It will be published on ' . $schedule->format('l jS \\o\\f F \\a\\t h:i A'));
             return $response_data;
         }
     }
 }
开发者ID:anchetaWern,项目名称:ahead,代码行数:53,代码来源:ApiController.php

示例2: scopeOld

 /**
  * @param Builder $query
  */
 public function scopeOld(Builder $query)
 {
     $query->where('created_at', '<', Carbon::create()->subDays(10));
 }
开发者ID:KodiComponents,项目名称:module-email,代码行数:7,代码来源:EmailQueue.php

示例3: PaymentStore

 public function PaymentStore($id)
 {
     $user = Auth::user();
     $participant = Participant::find($id);
     $title = 'League Together - ' . $participant->event->club->name . ' Teams';
     $player = $participant->player;
     $club = $participant->event->club;
     $cart = Cart::contents(true);
     $uuid = Uuid::generate();
     //Addition for stub feature
     $follow = Follower::where("user_id", "=", $user->id)->FirstOrFail();
     //check if follower equal club
     if ($follow->club_id != $club->id) {
         $param = array('ccnumber' => str_replace('_', '', Input::get('card')), 'ccexp' => sprintf('%02s', Input::get('month')) . Input::get('year'), 'cvv' => Input::get('cvv'), 'address1' => Input::get('address'), 'city' => Input::get('city'), 'state' => Input::get('state'), 'zip' => Input::get('zip'), 'discount' => Input::get('discount'), 'club' => $club->id, 'firstname' => $user->profile->firstname, 'lastname' => $user->profile->lastname, 'phone' => $user->profile->mobile);
     } else {
         $param = array('customer_vault_id' => $user->profile->customer_vault, 'discount' => Input::get('discount'), 'club' => $club->id);
     }
     $payment = new Payment();
     $transaction = $payment->sale($param);
     if ($transaction->response == 3 || $transaction->response == 2) {
         return Redirect::action('ParticipantController@paymentCreate', array($participant->id))->with('error', $transaction->responsetext);
     } else {
         foreach (Cart::contents() as $item) {
             $payment->id = $uuid;
             $payment->customer = $user->profile->customer_vault;
             $payment->transaction = $transaction->transactionid;
             $payment->subtotal = $transaction->subtotal;
             $payment->service_fee = $transaction->fee;
             $payment->total = $transaction->total;
             $payment->promo = $transaction->promo;
             $payment->tax = $transaction->tax;
             $payment->discount = $transaction->discount;
             $payment->club_id = $club->id;
             $payment->user_id = $user->id;
             $payment->player_id = $item->player_id;
             $payment->event_type = $participant->event->type_id;
             $payment->type = $transaction->type;
             $payment->save();
             $salesfee = $item->price / getenv("SV_FEE") - $item->price;
             $sale = new Item();
             $sale->description = $item->name;
             $sale->quantity = $item->quantity;
             $sale->price = $item->price;
             $sale->fee = $salesfee;
             $sale->participant_id = $participant->id;
             $sale->payment_id = $uuid;
             $sale->event_id = $participant->event->id;
             $sale->save();
             $participant->accepted_on = Carbon::Now();
             $participant->accepted_by = $user->profile->firstname . ' ' . $user->profile->lastname;
             $participant->accepted_user = $user->id;
             $participant->method = $item->type;
             $participant->status = 1;
             $participant->save();
             //create payments plan schedule
             if ($item->type == "plan") {
                 $subtotal = $participant->plan->getOriginal('recurring');
                 $fee = $subtotal / getenv("SV_FEE") - $subtotal;
                 $total = $fee + $subtotal;
                 for ($x = 1; $x < $participant->plan->recurrences + 1; $x++) {
                     $today = Carbon::now();
                     $today->addMonths($x);
                     $payon = $participant->plan->getOriginal('on');
                     //make sure the payday is a valid day
                     if ($payon == 31) {
                         if ($today->month == 2) {
                             $payon = 28;
                         }
                         if ($today->month == 4 || $today->month == 6 || $today->month == 9 || $today->month == 11) {
                             $payon = 30;
                         }
                     }
                     $payday = Carbon::create($today->year, $today->month, $payon, 0);
                     $schedule = new SchedulePayment();
                     $schedule->date = $payday;
                     $schedule->description = "Membership Team " . $participant->event->name;
                     $schedule->subtotal = number_format($subtotal, 2);
                     $schedule->fee = number_format($fee, 2);
                     $schedule->total = number_format($total, 2);
                     $schedule->plan_id = $participant->plan->id;
                     $schedule->club_id = $club->id;
                     $schedule->participant_id = $participant->id;
                     $status = $schedule->save();
                     if (!$status) {
                         return "We process your payment but and error occurred in the process, please contact us: support@leaguetogether.com Error# 597";
                     }
                 }
                 //end for loop
             }
             //end if plan
         }
         //email receipt
         $payment->receipt($transaction, $club->id, $item->player_id);
         $data = array('club' => $club, 'player' => $player, 'user' => $user, 'participant' => $participant);
         $mail = Mail::send('emails.notification.event.accept', $data, function ($message) use($user, $club, $participant) {
             $message->from('C2C@leaguetogether.com', 'C2C Lacrosse')->to($user->email, $participant->accepted_by)->subject("Thank you for joining our event | " . $club->name);
             foreach ($club->users()->get() as $value) {
                 $message->bcc($value->email, $club->name);
             }
         });
//.........这里部分代码省略.........
开发者ID:illuminate3,项目名称:league-production,代码行数:101,代码来源:ParticipantController.php

示例4: isset

        <th>#</th>
        <th>Nazwa użytkownika</th>
        <th style="width: 80px">Treści</th>
        <th style="width: 100px">Komentarze</th>
        <th style="width: 80px">Wpisy</th>
        <th style="width: 60px">UV</th>
        <th style="width: 60px">DV</th>
    </tr>
    </thead>
    <tbody>

    @foreach ($users as $index => $user)
    <tr @if(Auth::check() && $user->user_id == Auth::id()) class="warning" @endif>
        <td>{!! ( $index + $users->firstItem() ) !!}</td>
        <?php 
$day = Carbon::now()->diffInDays(Carbon::create(2013, 1, 1));
$query = \Strimoid\Models\DailyAction::where('user_id', $user->user_id)->groupBy('day')->orderBy('day', 'asc');
if (isset($group)) {
    $query->where('group_id', $group->getKey());
}
$results = $query->lists('points', 'day');
$chartData = [];
for ($i = $day; $i >= $day - 30; $i--) {
    $chartData[$i] = isset($results[$i]) ? $results[$i] : 0;
}
?>
        <td>
            <img src="{!! $user->user->getAvatarPath() !!}" style="width: 20px; height: 20px">
            <a href="{!! route('user_profile', $user->user) !!}">{!! $user->user->name !!}</a>
            <img src="https://chart.googleapis.com/chart?chs=100x20&cht=ls&chco=0077CC&chf=bg,s,FFFFFF00&chds=a&chd=t:{!! implode(',', $chartData) !!}" class="pull-right">
        </td>
开发者ID:vegax87,项目名称:Strimoid,代码行数:31,代码来源:ranking.blade.php

示例5: createPost

 public function createPost()
 {
     $user_id = Auth::user()->id;
     $rules = array('content' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         if (Input::has('ajax')) {
             return array('type' => 'danger', 'messages' => $validator->messages());
         } else {
             return Redirect::to('/post/new')->withErrors($validator)->withInput();
         }
     }
     $content = Input::get('content');
     $post_now = Input::get('post_now');
     $schedule_type = Input::get('schedule');
     if (empty($schedule_type)) {
         $schedule_type = Setting::where('user_id', '=', $user_id)->pluck('schedule_id');
     }
     $schedule_id = Settings::where('user_id', '=', $user_id)->pluck('schedule_id');
     $current_datetime = Carbon::now();
     $schedule = Carbon::now();
     if ($post_now == '0' && $schedule_type != 'custom') {
         $schedule_id = $schedule_type;
         $interval = Schedule::find($schedule_id);
         if ($interval->rule == 'add') {
             $schedule = $current_datetime->modify('+ ' . $interval->period);
         } else {
             if ($interval->rule == 'random') {
                 $current_day = date('d');
                 $from_datetime = Carbon::now();
                 $to_datetime = $from_datetime->copy()->modify('+ ' . $interval->period);
                 $days_to_add = $from_datetime->diffInDays($to_datetime);
                 $day = mt_rand($current_day, $current_day + $days_to_add);
                 $hour = mt_rand(1, 23);
                 $minute = mt_rand(0, 59);
                 $second = mt_rand(0, 59);
                 //year, month and timezone is null
                 $schedule = Carbon::create(null, null, $day, $hour, $minute, $second, null);
             }
         }
         if (empty($schedule)) {
             $schedule = $current_datetime->addHours(1);
         }
     } else {
         $schedule = Carbon::parse(Input::get('schedule_value'));
     }
     $networks = Input::get('network');
     if (empty($networks)) {
         $networks = Setting::where('user_id', '=', $user_id)->pluck('default_networks');
         $networks = json_decode($networks, true);
     }
     $post = new Post();
     $post->user_id = $user_id;
     $post->content = $content;
     $post->date_time = $schedule->toDateTimeString();
     $post->save();
     $post_id = $post->id;
     foreach ($networks as $network_id) {
         $post_network = new PostNetwork();
         $post_network->user_id = $user_id;
         $post_network->post_id = $post_id;
         $post_network->network_id = $network_id;
         $post_network->status = 1;
         $post_network->save();
     }
     Queue::later($schedule, 'SendPost@fire', array('post_id' => $post_id));
     if (Input::has('ajax')) {
         return array('type' => 'success', 'text' => 'Your post was scheduled! It will be published on ' . $schedule->format('l jS \\o\\f F \\a\\t h:i A'));
     }
     return Redirect::to('/post/new')->with('message', array('type' => 'success', 'text' => 'Your post was scheduled! It will be published on ' . $schedule->format('l jS \\o\\f F \\a\\t h:i A')));
 }
开发者ID:anchetaWern,项目名称:ahead,代码行数:71,代码来源:PostController.php

示例6: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     // if (!App::isDownForMaintenance() && App::environment() == 'production')
     // 	return $this->error('Application must be in maintenance mode to run this command in production environment');
     \DB::disableQueryLog();
     //get specific id to update if requested
     $arguments = $this->argument();
     $specific_id_arg = null;
     if (!empty($arguments['id'])) {
         $specific_id_arg = (int) $arguments['id'];
     }
     //get options
     $options = $this->option();
     try {
         $start_carbon = \Carbon::create();
         if (is_null($specific_id_arg)) {
             $this->infoOutput('Start products update (' . $start_carbon . ')...');
         } else {
             $this->infoOutput('Start products update for id ' . $specific_id_arg . ' (' . $start_carbon . ')...');
         }
         $this->setCronJob();
         $this->setInitialLastUpdatedId();
         $products_to_update = $this->getProductsToUpdate($specific_id_arg);
         //if we cant find any products to update, update cron job and exit
         if (!$products_to_update) {
             $this->updateCronJob($this->job_fail_status, 0, 0);
             $this->infoOutput('No products available to update');
             return;
         }
         while ($products_to_update) {
             $last_id_updated = $this->updateProducts($products_to_update);
             $this->last_id_updated = $last_id_updated;
             //if a specific id wasnt requested, get next set of products
             if (!$specific_id_arg) {
                 $products_to_update = $this->getProductsToUpdate();
             } else {
                 $products_to_update = null;
             }
         }
         $end_carbon = \Carbon::create();
         $this->infoOutput('Updates Completed: (' . $end_carbon . ')');
         $this->infoOutput('Total products updated: ' . $this->updated_product_count);
         $this->infoOutput('Hours Elapsed: ' . $end_carbon->diffInHours($start_carbon));
         $this->infoOutput('Minutes Elapsed: ' . $end_carbon->diffInMinutes($start_carbon));
         $this->infoOutput('Seconds Elapsed: ' . $end_carbon->diffInSeconds($start_carbon));
         if ($options['mail-notification']) {
             $this->sendMailNotification($this->mail_data);
         }
     } catch (\Exception $e) {
         // $this->updateCronJob($this->job_fail_status, null, $this->last_id_updated);
         throw $e;
     }
 }
开发者ID:ryanrobertsname,项目名称:giftertipster.com,代码行数:58,代码来源:UpdateProducts.php

示例7: PaymentStoreTeam

 public function PaymentStoreTeam($club, $id)
 {
     $user = Auth::user();
     $team = Team::find($id);
     $club = Club::find($club);
     $cart = Cart::contents(true);
     $uuid = Uuid::generate();
     $uuidMember = Uuid::generate();
     //Addition for stub feature
     $follow = Follower::where("user_id", "=", $user->id)->FirstOrFail();
     $title = 'League Together - ' . $team->club->name . ' Teams';
     //check if follower equal club
     if ($follow->club_id != $club->id) {
         $param = array('ccnumber' => str_replace('_', '', Input::get('card')), 'ccexp' => sprintf('%02s', Input::get('month')) . Input::get('year'), 'cvv' => Input::get('cvv'), 'address1' => Input::get('address'), 'city' => Input::get('city'), 'state' => Input::get('state'), 'zip' => Input::get('zip'), 'discount' => Input::get('discount'), 'club' => $club->id, 'firstname' => $user->profile->firstname, 'lastname' => $user->profile->lastname, 'phone' => $user->profile->mobile);
     } else {
         $param = array('customer_vault_id' => $user->profile->customer_vault, 'discount' => Input::get('discount'), 'club' => $club->id);
     }
     $payment = new Payment();
     $transaction = $payment->sale($param);
     if ($transaction->response == 3 || $transaction->response == 2) {
         return Redirect::action('ClubPublicController@PaymentCreateTeam', array($club->id, $team->id))->with('error', $transaction->responsetext);
     } else {
         foreach (Cart::contents() as $item) {
             $player = Player::find($item->player_id);
             //default from team
             $due = $team->getOriginal('due');
             $early_due = $team->getOriginal('early_due');
             $early_due_deadline = $team->getOriginal('early_due_deadline');
             $member = new Member();
             $member->id = $uuidMember;
             $member->firstname = $player->firstname;
             $member->lastname = $player->lastname;
             $member->due = $due;
             $member->early_due = $early_due;
             $member->early_due_deadline = $early_due_deadline;
             $member->plan_id = $team->plan_id;
             $member->player_id = $player->id;
             $member->team_id = $item->team_id;
             $member->accepted_on = Carbon::Now();
             $member->accepted_by = $user->profile->firstname . ' ' . $user->profile->lastname;
             $member->accepted_user = $user->id;
             $member->method = $item->type;
             $member->status = 1;
             $member->save();
             $payment->id = $uuid;
             $payment->customer = $user->profile->customer_vault;
             $payment->transaction = $transaction->transactionid;
             $payment->subtotal = $transaction->subtotal;
             $payment->service_fee = $transaction->fee;
             $payment->total = $transaction->total;
             $payment->promo = $transaction->promo;
             $payment->tax = $transaction->tax;
             $payment->discount = $transaction->discount;
             $payment->club_id = $club->id;
             $payment->user_id = $user->id;
             $payment->player_id = $item->player_id;
             $payment->event_type = null;
             $payment->type = $transaction->type;
             $payment->save();
             $salesfee = $item->price / getenv("SV_FEE") - $item->price;
             $sale = new Item();
             $sale->description = $item->name;
             $sale->quantity = $item->quantity;
             $sale->price = $item->price;
             $sale->fee = $salesfee;
             $sale->member_id = $uuidMember;
             $sale->team_id = $item->team_id;
             $sale->payment_id = $uuid;
             $sale->save();
             $member = Member::find($uuidMember);
             //create payments plan schedule
             if ($item->type == "plan") {
                 $subtotal = $member->plan->getOriginal('recurring');
                 $fee = $subtotal / getenv("SV_FEE") - $subtotal;
                 $total = $fee + $subtotal;
                 for ($x = 1; $x < $member->plan->recurrences + 1; $x++) {
                     $today = Carbon::now();
                     $today->addMonths($x);
                     $payon = $member->plan->getOriginal('on');
                     //make sure the payday is a valid day
                     if ($payon == 31) {
                         if ($today->month == 2) {
                             $payon = 28;
                         }
                         if ($today->month == 4 || $today->month == 6 || $today->month == 9 || $today->month == 11) {
                             $payon = 30;
                         }
                     }
                     $payday = Carbon::create($today->year, $today->month, $payon, 0);
                     $schedule = new SchedulePayment();
                     $schedule->date = $payday;
                     $schedule->description = "Membership Team " . $member->team->name;
                     $schedule->subtotal = number_format($subtotal, 2);
                     $schedule->fee = number_format($fee, 2);
                     $schedule->total = number_format($total, 2);
                     $schedule->plan_id = $member->plan->id;
                     $schedule->club_id = $club->id;
                     $schedule->member_id = $member->id;
                     $status = $schedule->save();
                     if (!$status) {
//.........这里部分代码省略.........
开发者ID:illuminate3,项目名称:league-production,代码行数:101,代码来源:ClubPublicController.php

示例8: updateQuizSchedule

 public function updateQuizSchedule($schedule_id)
 {
     $user_id = Auth::user()->id;
     $quiz = Input::get('quiz');
     $class = Input::get('class');
     $start_time = Input::get('start_time');
     $end_time = Input::get('end_time');
     $start_timestamp_array = $this->timestampToArray($start_time);
     extract($start_timestamp_array);
     $datetime_from = Carbon::create($year, $month, $day, $hour, $minute, $second)->toDateTimeString();
     $end_timestamp_array = $this->timestampToArray($end_time);
     extract($end_timestamp_array);
     $datetime_to = Carbon::create($year, $month, $day, $hour, $minute, $second)->toDateTimeString();
     $quiz_id = DB::table('quiz')->where('title', '=', $quiz)->pluck('id');
     $class_id = DB::table('classes')->where('name', '=', $class)->pluck('id');
     $quiz_schedule = QuizSchedule::find($schedule_id);
     $quiz_schedule->user_id = $user_id;
     $quiz_schedule->quiz_id = $quiz_id;
     $quiz_schedule->class_id = $class_id;
     $quiz_schedule->datetime_from = $datetime_from;
     $quiz_schedule->datetime_to = $datetime_to;
     $quiz_schedule->save();
     return Redirect::back()->with('message', array('type' => 'success', 'text' => 'Quiz Schedule Updated!'));
 }
开发者ID:anchetaWern,项目名称:shotgun,代码行数:24,代码来源:AdminController.php

示例9: onlyOncefillerAttributes

 /**
  * @return array
  */
 protected static function onlyOncefillerAttributes()
 {
     return array('uuid' => uniqid('System'), 'createby_id' => 1, 'lastupdateby_id' => 1, 'created_at' => Carbon::create(), 'updated_at' => Carbon::create());
 }
开发者ID:emayk,项目名称:ics,代码行数:7,代码来源:Locations.php


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