/** * @test */ public function it_has_a_timezone_attribute() { $carbon = Carbon::parse('today')->addDays(7); $appointment = $this->createAppointmentPresenter(['start_at' => $carbon, 'finish_at' => $carbon->addHours(1)]); $appointment->setTimezone('Europe/Madrid'); $this->assertInternalType('string', $appointment->timezone()); }
/** * 金曜日になると今週の週報タグを生成する */ public function buildNextWeekTag() { \Log::info('Start generate tag of This week. '); $dt = new Carbon(); // $dt->setTestNow($dt->createFromDate(2015, 5, 31)); if ($dt->now()->dayOfWeek === Carbon::FRIDAY) { //翌月 $nextMonth = $dt->parse('next month')->month; // 現在が何週目か \Log::info('今日は' . $dt->now()->month . '月の第' . $dt->now()->weekOfMonth . '週目です'); //今週の金曜を取得 $thisFriday = $dt->parse('this friday'); \Log::info('来週の金曜は' . $thisFriday); // 月またぎの場合 if ($thisFriday->month === $nextMonth) { \Log::info($thisFriday->year . '年の' . $thisFriday->month . '月の第' . $thisFriday->weekOfMonth . '週目です'); $nextWeekTag = '週報@' . $thisFriday->year . '年' . $thisFriday->month . '月第' . $thisFriday->weekOfMonth . '週'; $this->tag->tag = $nextWeekTag; $this->tag->save(); } else { \Log::info('翌週は' . $thisFriday->month . '月の第' . $thisFriday->weekOfMonth . '週目です'); $nextWeekTag = '週報@' . $thisFriday->year . '年' . $thisFriday->month . '月第' . $thisFriday->weekOfMonth . '週'; $this->tag->tag = $nextWeekTag; $this->tag->save(); } \Log::info('End generate tag'); } else { \Log::info('Today is not Friday.'); } }
/** * Handle the event. * * @param Event $event * @return void */ public function handle(Event $event) { /** * Create Voting */ $vote_open_date = $this->carbon->parse($event->voting_date); $vote_close_date = $vote_open_date->copy()->addMinutes(config('defaults.project.voting_span_time')); $this->dispatch(new CreateVotingCommand($event->model, $vote_open_date, $vote_close_date)); }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create(Request $request) { $inquiry = DB::table('inquiries')->orderBy('stop', 'desc')->first(); $start = Carbon::parse($inquiry->stop)->format('Y-m-d'); $stop = Carbon::parse($inquiry->stop)->addWeek()->format('Y-m-d'); // echo $start; // $inputData = $request->all(); // if ($start>$inputData['start']) // { // echo "start is kleiner"; // } // echo $inputData['start']; $this->validate($request, ['inquiry' => 'required|max:255', 'awnser' => 'required|max:255', 'option1' => 'required|max:255', 'option2' => 'required|max:255', 'option3' => 'required|max:255', 'start' => 'required|date:after:' . $start, 'stop' => 'required|date:after:' . $stop]); $inputData = $request->all(); $inquiry = new Inquiry(); $inquiry->question = $inputData['inquiry']; $inquiry->awnser = $inputData['awnser']; $inquiry->option1 = $inputData['option1']; $inquiry->option2 = $inputData['option2']; $inquiry->option3 = $inputData['option3']; $inquiry->start = $inputData['start']; $inquiry->stop = $inputData['stop']; $inquiry->save(); return redirect()->route('home'); }
public function __construct() { $from = Input::get('from'); $this->from = $from ? Carbon::parse($from) : null; $to = Input::get('to'); $this->to = $to ? Carbon::parse($to) : null; }
/** * Formats the deleted_at timestamp. * * @param string $deleted_at * * @return string|null */ public function getDeletedAtAttribute($deleted_at) { if (array_key_exists('deleted_at', $this->attributes)) { return Carbon::parse($deleted_at)->format('Y-m-d h:i A'); } return null; }
public function carian() { $tarikh = Carbon::parse(\Input::get('tarikh')); $bil = 1; $laporans = Laporan::latest('tarikh')->where('tarikh', 'like', $tarikh . '%')->where('user', Auth::user()->username)->latest('tarikh')->get(); return View('members.technician.carian', compact('bil', 'laporans', 'tarikh')); }
/** * {@inheritDoc} */ public function init() { $this->fillFromConfig(['mode', 'minDate', 'maxDate']); $this->mode = strtolower($this->mode); $this->minDate = is_integer($this->minDate) ? Carbon::createFromTimestamp($this->minDate) : Carbon::parse($this->minDate); $this->maxDate = is_integer($this->maxDate) ? Carbon::createFromTimestamp($this->maxDate) : Carbon::parse($this->maxDate); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $client = Client::findOrFail($id); $projects = Client::find($id)->projects()->orderBy('id', 'desc')->get(); $invoices = Client::find($id)->invoices()->orderBy('id', 'desc')->get(); $quotes = Client::find($id)->quotes()->orderBy('id', 'desc')->get(); $client->client_id = $client->id + 999; foreach ($invoices as $invoice) { $issue_date = Carbon::parse($invoice->issue_date); $due_date = Carbon::parse($invoice->due_date); $now = Carbon::now(); if ($now > $due_date) { $invoice->is_overdue = true; } else { $invoice->is_overdue = false; } $invoice->readable_specific_id = $invoice->client_specific_id; if ($invoice->client_specific_id < 10) { $invoice->readable_specific_id = sprintf("%02d", $invoice->client_specific_id); } $invoice->terms_diff = $issue_date->diffInDays($due_date); } foreach ($quotes as $quote) { if ($quote->client_specific_id < 10) { $quote->client_specific_id = sprintf("%02d", $quote->client_specific_id); } } foreach ($projects as $project) { $project->latest_activity = $project->project_activity()->latest()->first(); } $totalPaid = $client->invoices()->paid()->sum('amount'); $totalOutstanding = $client->invoices()->active()->sum('amount'); return view('app.client', ['client' => $client, 'projects' => $projects, 'invoices' => $invoices, 'quotes' => $quotes, "total_paid" => $totalPaid, 'total_outstanding' => $totalOutstanding]); }
public function getSales() { $from = Input::get('from'); $to = Input::get('to'); $all_orders = Order::where(function ($q) use($from, $to) { if ($from) { $q->where('created_at', '>=', Carbon::parse($from)); } if ($to) { $q->where('created_at', '<=', Carbon::parse($to)); } })->get(); $paid_orders = Order::where(function ($q) use($from, $to) { $q->where('state', '1'); if ($from) { $q->where('created_at', '>=', Carbon::parse($from)); } if ($to) { $q->where('created_at', '<=', Carbon::parse($to)); } })->get(); $total_summ_paid_orders = 0; foreach ($paid_orders as $order) { $total_summ_paid_orders += $order->sum; } $period = ['from' => $from, 'to' => $to, 'text' => $this->period_text($from, $to)]; return view('admin.stat.sales', ['paid_orders' => $paid_orders, 'orders' => $all_orders, 'total_summ_paid_orders' => number_format($total_summ_paid_orders, 2, ',', ' '), 'period' => $period]); }
/** * Update the specified resource in storage. * * @param Request $request * @return Response * @internal param User $user * @internal param int $id */ public function update(Request $request) { $this->validate($request, ['first_name' => 'required|max:255', 'last_name' => 'required|max:255', 'sex' => 'required', 'date_of_birth' => 'required']); $request['date_of_birth'] = Carbon::parse($request->get('date_of_birth')); Auth::user()->update($request->all()); return redirect(url('/users/show'))->with('message', "Successfully updated Your info."); }
public function agendaJson(Request $request) { // load of actions between start and stop provided by calendar js if ($request->has('start') && $request->has('end')) { $actions = \App\Action::with('group')->where('start', '>', Carbon::parse($request->get('start')))->where('stop', '<', Carbon::parse($request->get('end')))->orderBy('start', 'asc')->get(); } else { $actions = \App\Action::with('group')->orderBy('start', 'asc')->get(); } $event = ''; $events = ''; foreach ($actions as $action) { $event['id'] = $action->id; $event['title'] = $action->name; $event['description'] = $action->body . ' <br/> ' . $action->location; $event['body'] = filter($action->body); $event['summary'] = summary($action->body); $event['location'] = $action->location; $event['start'] = $action->start->toIso8601String(); $event['end'] = $action->stop->toIso8601String(); $event['url'] = action('ActionController@show', [$action->group->id, $action->id]); $event['group_url'] = action('ActionController@index', [$action->group->id]); $event['group_name'] = $action->group->name; $event['color'] = $action->group->color(); $events[] = $event; } return $events; }
/** * Execute the console command. * * @return mixed */ public function handle() { $this->info('Remove no longer used logs'); $difference = Carbon::parse("-1 months"); $logs = ApiLog::onlyTrashed()->where('deleted_at', '<', $difference)->latest()->forceDelete(); $this->info('Done!'); }
/** * Sends a message for an appointment * * @param Appointment $appointment The appointment to remind * * @return void */ private function _remindAbout($appointment) { $recipientName = $appointment->name; $time = Carbon::parse($appointment->when, 'UTC')->subMinutes($appointment->timezoneOffset)->format('g:i a'); $message = "Hello {$recipientName}, this is a reminder that you have an appointment at {$time}!"; $this->_sendMessage($appointment->phoneNumber, $message); }
public static function groupByDateTime($data, $dateFormat) { $data = static::toCollection($data)->groupBy(function ($date) use($dateFormat) { return Carbon::parse($date->created_at)->format($dateFormat); }); return static::sortByKeys($data); }
public function index() { $id = Auth::id(); $user = User::find($id); $expire_date = Carbon::parse($user->activated_at)->addMonth($user->duration); return View('user.index')->with('expire_date', $expire_date); }
/** * Execute the console command. * * @return void */ public function fire() { $tasks = Task::where('date', '>=', Carbon::parse(date('d-m-Y')))->where('date', '<=', Carbon::parse(date('d-m-Y'))->addDay(7))->orderBy('date', 'asc')->get(); \Mail::send('emails.remainder', ['tasks' => $tasks], function ($m) { $m->to(env('REMAINDER_EMAIL'), env('REMAINDER_NAME'))->subject('[SUN TASK] Your Task Reminder.'); }); }
public function getPublishedAtAttribute($value) { if ($value == '0000-00-00 00:00:00') { return 'no date'; } return Carbon::parse($value)->format('d/m/Y h:i:s'); }
public function getSlot() { //Slot time $slotDate = Carbon::parse(Input::get('date')); $todayDate = Carbon::now('Asia/Kolkata'); $venueId = Input::get('venueId'); $slots = VenueRoomSlot::where('date', $slotDate->toDateString())->with('associatedRoom')->with('associatedVenue')->with('bookingDetail')->whereHas('associatedRoom', function ($q) use($venueId) { $q->where('venue_id', '=', $venueId); })->get(); // dd($slots); //Floor wise data sort karna hai //Frontend pe dikhane ke liye $data = array(); if (!is_null($slots->first()) && $slotDate > $todayDate->subDay(1)) { $currentFloor = $slots->first()->associatedRoom->room[0]; $i = 0; foreach ($slots as $slot) { if ($slot->associatedRoom->room[0] != $currentFloor) { $currentFloor = $slot->associatedRoom->room[0]; $i = $i + 1; } $data['floor'][$i][] = $slot; } } $response['data'] = $data; return json_encode($response); }
private function countModelsByTime($attr, $model_raw, $first, $last, $date_format) { $model = "\\" . $model_raw; date_default_timezone_set('America/New_York'); $today = date('Y-m-d'); $GLOBALS['date_format'] = $date_format; // Get the information requested $days_fetch = $model::select($attr)->whereBetween((string) $attr, array(new DateTime($first), new DateTime($last)))->orderBy($attr, 'asc')->get(); if ($attr === "created_at") { $days_fetch_grouped = $days_fetch->groupBy(function ($date) { return Carbon::parse($date->created_at)->format($GLOBALS['date_format']); }); $today_fetch = $model::select($attr)->whereRaw('date(created_at) = ?', [Carbon::now()->format('Y-m-d')])->get(); } else { $days_fetch_grouped = $days_fetch->groupBy(function ($date) { return Carbon::parse($date->updated_at)->format($GLOBALS['date_format']); }); $today_fetch = $model::select($attr)->whereRaw('date(updated_at) = ?', [Carbon::now()->format('Y-m-d')])->get(); } $days = array(); foreach ($days_fetch_grouped as $key => $value) { $days["days"][$key] = count($days_fetch_grouped[$key]); $days["total"] = count($days_fetch); $days["today"] = count($today_fetch); } // Also get the total in the range and today return $days; }
public function getLastDateAttribute($value) { $date = \Carbon\Carbon::parse($value); $monthes = ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь']; $text_date = $monthes[$date->month - 1] . ' ' . $date->year; return $text_date; }
public function index(\PlayFooty\Event $event) { $nextWeek = Carbon::parse($event->event_date)->addDays(7); $event->event_date = $nextWeek->format('Y-m-d'); $viewData = $event->toArray(); return view('matches.new-match')->with(['data' => $viewData]); }
public static function checkNextMonth() { if (\Auth::user()->isAdmin()) { $aboutfacture = ''; // $check = \Auth::user()->created_at->addMinutes(10); $next_month = Carbon::now()->firstOfMonth()->addMonth()->toDateString(); $ok = \Auth::user()->schoolyears()->where('current', 1)->first(); if ($ok) { if ($ok->type == 'Trim') { if (Carbon::parse($next_month)->between($ok->startch1, $ok->endch3) && Carbon::now()->month <= 5) { $aboutfacture = 'yes'; } else { $aboutfacture = 'no'; } return $aboutfacture; } if ($ok->type == 'Semis') { if (Carbon::parse($next_month)->between($ok->startch1, $ok->endch2) && Carbon::now()->month <= 5) { $aboutfacture = 'yes'; } else { $aboutfacture = 'no'; } return $aboutfacture; } } } }
public function notifyAction() { $id = 1; $settings = R::load('settings', $id); $time_before = c::now()->modify('+' . $settings->time_before)->toDateString(); $transport = \Swift_SmtpTransport::newInstance($settings->mail_host, $settings->mail_port)->setUsername($settings->mail_username)->setPassword($settings->mail_password); $mailer = \Swift_Mailer::newInstance($transport); $client = new \Services_Twilio($settings->twilio_sid, $settings->twilio_token); $recepients = R::findAll('recepients'); $events = R::find("events", "is_enabled = 1 AND date = '{$time_before}'"); foreach ($events as $event) { foreach ($recepients as $recepient) { $subject = preg_replace(array('/{title}/', '/{date}/'), array($event->title, $event->date), $settings->subject); $end_date = c::parse($event->date)->modify('+' . $event->days . ' days')->toDateString(); $body_patterns = array('/{name}/', '/{title}/', '/{start_date}/', '/<!(\\w+) ({\\w+})>/'); $body_replacements = array($settings->name, $event->title, $event->date, "\$1 {$end_date}"); if ($event->days == 1) { $body_replacements[3] = ''; } $body = preg_replace($body_patterns, $body_replacements, $settings->msg_template); if ($recepient->email && $settings->mail_username && $settings->mail_password) { $message = \Swift_Message::newInstance()->setSubject($subject)->setBody($body)->setFrom(array($settings->email => $settings->name))->setTo(array($recepient->email => $recepient->name)); try { $response = $mailer->send($message); } catch (\Exception $e) { //todo: log error } } else { if ($recepient->phone_number && $settings->twilio_sid && $settings->twilio_token && $settings->twilio_phonenumber) { $message = $client->account->messages->sendMessage($settings->twilio_phonenumber, $recepient->phone_number, $body); } } } } }
public function __construct($ticket, User $requester) { $this->ticket = $ticket; $this->requester = $requester; // Carbonize the deliver_by date. $this->ticket['deliver_by'] = array_key_exists('deliver_by', $ticket) ? $this->ticket['deliver_by'] = Carbon::parse($ticket['deliver_by'], 'UTC')->setTimezone('America/New_York') : null; }
/** * Validar la entrada de datos * @param campo $campo * @param valor $valor * @return mixed */ protected function _sanitizeInput($campo, $valor) { switch ($campo) { case 'start_date': $date = Carbon::parse($valor); $result = $date->format('Y-m-d'); break; case 'end_date': $date = Carbon::parse($valor); $result = $date->format('Y-m-d'); break; case 'query_by': if ($valor == "dia") { $result = "dia"; } else { if ($valor == "mes") { $result = "mes"; } else { $result = "fecha"; } } break; case 'network': if ($valor == "facebook") { $result = "facebook"; } else { $result = "twitter"; } break; default: $result = $valor; break; } return $result; }
/** * Send campagne * * @return \Illuminate\Http\Response */ public function campagne(Request $request) { // Get campagne $campagne = $this->campagne->find($request->input('id')); $date = $request->input('date', null); //set or update html $html = $this->worker->html($campagne->id); $this->mailjet->setList($campagne->newsletter->list_id); // list id // Sync html content to api service and send to newsletter list! $response = $this->mailjet->setHtml($html, $campagne->api_campagne_id); if (!$response) { throw new \designpond\newsletter\Exceptions\CampagneUpdateException('Problème avec la préparation du contenu'); } /* * Send at specified date or delay for 15 minutes before sending just in case */ $toSend = $date ? \Carbon\Carbon::parse($date) : \Carbon\Carbon::now()->addMinutes(15); $result = $this->mailjet->sendCampagne($campagne->api_campagne_id, $toSend->toIso8601String()); if (!$result['success']) { throw new \designpond\newsletter\Exceptions\CampagneSendException('Problème avec l\'envoi' . $result['info']['ErrorMessage'] . '; Code: ' . $result['info']['StatusCode']); } // Update campagne status $this->campagne->update(['id' => $campagne->id, 'status' => 'envoyé', 'updated_at' => date('Y-m-d G:i:s'), 'send_at' => $toSend]); alert()->success('Campagne envoyé!'); return redirect('build/newsletter'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Business $business, Request $request) { $this->log->info("BusinessServiceController: store: businessId:{$business->id}"); $dates = $request->get('vacancy'); $success = false; foreach ($dates as $date => $vacancy) { foreach ($vacancy as $serviceId => $capacity) { switch (trim($capacity)) { case '': // Dont update, leave as is $this->log->info("BusinessServiceController: store: [ADVICE] Blank vacancy capacity value businessId:{$business->id}"); break; default: $start_at = Carbon::parse($date . ' ' . $business->pref('start_at'))->timezone($business->timezone); $finish_at = Carbon::parse($date . ' ' . $business->pref('finish_at', '20:00:00'))->timezone($business->timezone); $vacancy = Vacancy::updateOrCreate(['business_id' => $business->id, 'service_id' => $serviceId, 'date' => $date], ['capacity' => intval($capacity), 'start_at' => $start_at, 'finish_at' => $finish_at]); $success = true; break; } } } if ($success) { Flash::success(trans('manager.vacancies.msg.store.success')); return redirect()->route('manager.business.show', [$business]); } $this->log->info("BusinessServiceController: store: [ADVICE] Nothing to update businessId:{$business->id}"); Flash::warning(trans('manager.vacancies.msg.store.nothing_changed')); return redirect()->back(); }
public function pepsi(Request $request) { /* $components = ['062BFFD1637011E5B83800FF59FBB323', '063278FF637011E5B83800FF59FBB323', '0631FF85637011E5B83800FF59FBB323', '062C796C637011E5B83800FF59FBB323', '0615D0AA637011E5B83800FF59FBB323', '06163FD0637011E5B83800FF59FBB323']; */ $components = ['08BA6275637011E5B83800FF59FBB323', '08BABBC7637011E5B83800FF59FBB323', '08BA0B96637011E5B83800FF59FBB323', '061BC1EB637011E5B83800FF59FBB323', '06229D04637011E5B83800FF59FBB323', '06232D26637011E5B83800FF59FBB323', '08BD2EDD637011E5B83800FF59FBB323', '08BD8844637011E5B83800FF59FBB323', '08BDE48E637011E5B83800FF59FBB323', '08BE401B637011E5B83800FF59FBB323', '08BE97FC637011E5B83800FF59FBB323', '08BEEB6C637011E5B83800FF59FBB323']; $data = []; $branches = \App\Models\Branch::orderBy('code')->get(); if ($request->input('year') != '' && $request->input('branchid') != '') { foreach ($components as $key => $value) { $date = \Carbon\Carbon::parse($request->input('year') . '-01-01'); $results = \App\Models\Purchase2::select(DB::raw('date, SUM(qty) AS qty, SUM(tcost) AS tcost'))->where('componentid', $value)->where('branchid', $request->input('branchid'))->where(DB::raw('YEAR(date)'), $request->input('year'))->groupBy(DB::raw('YEAR(date)'))->groupBy(DB::raw('MONTH(date)'))->get(); for ($i = 0; $i < 12; $i++) { $filtered = $results->filter(function ($item) use($date) { return $item->date->format('Y-m') == $date->format('Y-m') ? $item : null; }); $data[$key][$date->format('Y-m-d')] = $filtered->first(); $date->addMonth(); } } } if ($request->input('data') != '') { return $data; } return view('blank')->with('branches', $branches)->with('data', $data); }
public function generate($employeeid, Carbon $date, $timelogs) { $this->timelogs = $timelogs; $this->workHours = Carbon::parse($date->format('Y-m-d') . ' 00:00:00'); $this->otHours = Carbon::parse($date->format('Y-m-d') . ' 00:00:00'); for ($i = 1; $i < 5; $i++) { $log = $timelogs->where('employeeid', $employeeid)->where('txncode', $i)->sortBy('datetime')->first(); if (!is_null($log)) { switch ($i) { case 1: $this->timein = new Log($log); break; case 2: $this->breakin = new Log($log); break; case 3: $this->breakout = new Log($log); break; case 4: $this->timeout = new Log($log); break; } } } $this->checkBreak(); $this->computeWorkHours(); return $this; }