public function paymentByDay() { return static::select('id')->get()->where('type', 'payment')->andWhere('state', 'paid')->groupBy(function ($date) { return Carbon::parse($date->created_at)->format('d'); // grouping by months }); }
public function getObservationsByDate($missionId, $date) { $response = new ApiResponse(); if ($missionId != null) { $mission = Mission::with('devices')->find($missionId); if ($mission == null) { $response->status = 'error'; $response->message = ['id' => '', 'code' => 'mission_null', 'description' => 'The mission was not found']; return \Response::json($response); } $timestamp = \Carbon::parse($date)->timestamp; //for each device, get its observations foreach ($mission->devices as $device) { $deviceUUID = env('RADICAL_CITYNAME') . '.' . $mission->radical_service_id . '.' . $device->device_uuid; $obs = $this->radicalIntegrationManager->getMeasurementsByDeviceUUID($deviceUUID, $timestamp); $device->measurements = json_decode($obs); } $response->status = 'success'; $response->message = ['mission' => $mission]; return \Response::json($response); } else { $response->status = 'error'; $response->message = ['id' => '', 'code' => 'mission_id_null', 'description' => 'The missionId should not null']; return \Response::json($response); } }
/** * Display a listing of the resource. * * @return Response */ public function index() { $exclude = \App\EventCheckin::lists('sale_checkin_id'); $ticketsales = \App\Sale::where('created_at', '>', \Carbon::parse('1/31/2016'))->whereNotIn('cart_id', $exclude)->with('cartsBySale', 'cartsBySale.product')->get(); $checkedin = \App\Sale::where('created_at', '>', \Carbon::parse('1/31/2016'))->WhereIn('cart_id', $exclude)->with('cartsBySale', 'cartsBySale.product')->get(); return view('orders.index', compact('ticketsales', 'checkedin')); }
/** * Mutating date into readable format * @param $added_on */ public function getaddedOnAttribute($added_on) { if ($this->getMutatedData) { return Carbon::parse($added_on)->diffForHumans(); } return $added_on; }
public function printpdf($id) { $data['active'] = 'versheet'; $data['vs'] = Versheet::find($id); $day = Carbon::parse($data['vs']->tanggal); $data['day'] = $day; $pdf = PDF::loadView('templatesurat.verification', $data); return $pdf->stream(); }
public function storefromajax() { $sta = new STActivity(); $sta->site_id = Input::get('site'); $sta->mulai = Carbon::parse(Input::get('mulai')); $sta->selesai = Carbon::parse(Input::get('selesai')); $sta->activity = Input::get('activity'); $sta->save(); return Response::json($sta); }
public static function getEstadoResidencia($residencia_id, $fecha_inicial = null) { if ($fecha_inicial == null) { $fecha_inicial = Carbon::parse(Carbon::today()->year . "/" . "01/01"); } $estados = Solvencia::where('residencia_id', "=", $residencia_id)->where('año', ">=", $fecha_inicial->year)->orderBy("id", "desc")->get(); $estados = $estados->filter(function ($estado) use($fecha_inicial) { return $estado->año > $fecha_inicial->year or $estado->año == $fecha_inicial->year && $estado->mes >= $fecha_inicial->month; }); return $estados; }
function fire($job, $data = null) { $job->delete(); $flights = Flight::whereMissing(true)->select('flights.id', 'updates.timestamp')->join('positions', 'flights.id', '=', 'positions.flight_id')->join('updates', 'positions.update_id', '=', 'updates.id')->take(10000)->get(); foreach ($flights as $flight) { if (Carbon::now()->diffInMinutes(Carbon::parse($flight->timestamp)) >= 60) { $flight->delete(); // Log::info('queue:datafeed[' . $job->getJobId() . '] deleted flight #' . $flight->id . ', missing: ' . Carbon::now()->diffInMinutes(Carbon::parse($flight->timestamp))); } unset($flight); } }
/** * Display a listing of the resource. * GET /eventos * * @return Response */ public function index() { $eventos = Eventos::where('fecha_ini', '>=', Carbon::today())->orderby("fecha_ini", "asc")->orderby("tiempo_ini", "asc")->get(); $eventos->each(function ($evento) { $evento = array_add($evento, 'duracion', traducir_fecha(Carbon::parse($evento->fecha_ini . $evento->tiempo_ini)->diffForHumans(Carbon::parse($evento->fecha_fin . $evento->tiempo_fin)), true)); $evento['inicio'] = traducir_fecha(Carbon::parse($evento->fecha_ini . $evento->tiempo_ini)->toDayDateTimeString()); $evento['fin'] = traducir_fecha(Carbon::parse($evento->fecha_fin . $evento->tiempo_fin)->toDayDateTimeString()); foreach ($evento->areas() as $area) { $evento->area .= $area->nombre . ","; } }); return Response::json($eventos, 200); }
/** * put edit * * @return Response */ public function putEdit($todo) { $rules = array('title' => 'required'); $validator = Validator::make(Input::all(), $rules); if ($validator->passes()) { $todo->title = Input::get('title'); $todo->description = Input::get('description'); $todo->status = Input::get('status'); $todo->due_at = Carbon::parse(Input::get('due_at')); return $todo->save() ? Api::to(array('success', Lang::get('admin/todos/messages.create.success'))) ?: Redirect::to('admin/todos/' . $todo->id . '/edit')->with('success', Lang::get('admin/todos/messages.create.success')) : Api::to(array('error', Lang::get('admin/todos/messages.create.error'))) ?: Redirect::to('admin/todos/' . $todo->id . '/edit')->with('error', Lang::get('admin/todos/messages.create.error')); } else { return Api::to(array('error', Lang::get('admin/todos/messages.create.error'))) ?: Redirect::to('admin/todos/' . $todo->id . '/edit')->withErrors($validator); } }
public static function VeryPayment() { if ($user = Sentry::getUser()) { $dt = Carbon::now(); $payment = Payment::where('user_id', $user->id)->first(); $plan = Plan::find($payment->plan_id); $create = Carbon::parse($payment->created_at); if ($create->addDays($plan->time) > $dt) { return true; } else { return false; } } }
public function update($id) { $ac = Activity::find($id); $ac->user_id = Auth::user()->id; $ac->site_id = Input::get('site'); $ac->problem = Input::get('problem'); $ac->activity = Input::get('activity'); $ac->detail_activity = Input::get('dactivity'); $ac->mulai = Carbon::parse(Input::get('mulai')); $ac->selesai = Carbon::parse(Input::get('selesai')); $ac->save(); Session::flash('success', 'Data telah dibuat.'); return Redirect::to('/' . Auth::user()->role . '/activity'); }
/** * Parse datetime with Carbon. * * @param mixed|$time Carbon supported time * @param string|$timezone Output timezone, try to catch from users table if not set * * @return Carbon */ function datetime($time = null, $timezone = null, $reverse = false) { $defaultTz = config('app.timezone'); if (!$timezone && !empty(Auth::user()->timezone)) { $timezone = Auth::user()->timezone; } if (!in_array($timezone, timezone_identifiers_list())) { $timezone = false; } if ($timezone) { if ($time instanceof Carbon\Carbon) { return $time->tz($timezone); } return $reverse ? Carbon::parse($time, $timezone)->tz($defaultTz) : Carbon::parse($time, $defaultTz)->tz($timezone); } return Carbon::parse($time, $defaultTz); }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('infos')->delete(); $faker = \Faker\Factory::create(); foreach (range(1, 20) as $index) { $employee = Employee::all(); $originator = $employee->random(); $close_by = Employee::where('station', 'quality assurance')->first(); $issuedTo = $employee->random(); $major = 'major'; $year = Carbon::now('Asia/Manila')->format('y'); $info = Info::create(['control_id' => $year . "-" . sprintf("%'.04d", $index), 'customer' => $faker->randomElement(array_flatten(Option::all('customer')->toArray())), 'package_type' => $faker->firstNameFemale, 'device_name' => $faker->address, 'lot_id_number' => $faker->randomDigit, 'lot_quantity' => $faker->randomNumber(4), 'job_order_number' => $faker->randomElement(['0', '1', '2']), 'machine' => $faker->randomElement(['at01', 'at02', 'at03', 'at04', 'at05']), 'station' => $faker->randomElement(['pl1', 'pl2', 'pl3', 'pl4', 'pl5']), 'created_at' => $faker->dateTimeThisMonth, 'major' => $major, 'disposition' => $faker->randomElement(['use as is', 'ncmr#', 'rework', 'split lot', 'shutdown', 'shipback']), 'problem_description' => $faker->paragraph(2), 'failure_mode' => $faker->randomelement(['assembly', 'environment', 'machine', 'man', 'material', 'method / process']), 'discrepancy_category' => $faker->randomelement(['MISSING UNIT(S)', 'LOW YIELD', 'WRONG TRANSACTION', 'CANT CREATE', 'FOREIGN MATERIAL', 'WRONG MERGING', 'DATECODE DISCREPANCY', 'MARKING PROBLEM', 'MIXED DEVICE', 'BENT LEAD', 'LEAD CONTAMINATION', 'LEAD DISCOLORATION', 'LEAD COPLANARITY']), 'quantity' => $faker->randomNumber(4)]); CauseOfDefect::create(['info_id' => $info->id, 'cause_of_defect' => $faker->randomElement(['PRODUCTION', 'PROCESS', 'MAINTENANCE', 'FACILITIES', 'QUALITY ASSURANCE', 'OTHERS']), 'cause_of_defect_description' => $faker->paragraph(2), 'objective_evidence' => 'N/A']); ContainmentAction::create(['info_id' => $info->id, 'what' => $faker->paragraph(2), 'who' => $faker->name('male' | 'female'), 'objective_evidence' => 'N/A', 'created_at' => $info->created_at]); CorrectiveAction::create(['info_id' => $info->id, 'what' => $faker->paragraph(2), 'who' => $faker->name('male' | 'female'), 'objective_evidence' => 'N/A', 'created_at' => $info->created_at]); PreventiveAction::create(['info_id' => $info->id, 'what' => $faker->paragraph(2), 'who' => $faker->name('male' | 'female'), 'objective_evidence' => 'N/A', 'created_at' => $info->created_at]); QdnCycle::create(['info_id' => $info->id, 'cycle_time' => '24', 'production_cycle_time' => '24', 'process_engineering_cycle_time' => '24', 'quality_assurance_cycle_time' => '24', 'other_department_cycle_time' => '24', 'created_at' => $info->created_at]); InvolvePerson::create(['info_id' => $info->id, 'station' => $originator->station, 'originator_id' => $originator->user_id, 'originator_name' => $originator->name, 'receiver_id' => $issuedTo->user_id, 'receiver_name' => $issuedTo->name, 'created_at' => $info->created_at]); Closure::create(['info_id' => $info->id, 'containment_action_taken' => $faker->randomElement(['yes', 'no']), 'corrective_action_taken' => $faker->randomElement(['yes', 'no']), 'close_by' => $close_by->name, 'date_sign' => Carbon::parse($info->created_at)->addDay(), 'production' => $employee->where('department', 'production')->random()->name, 'process_engineering' => $employee->where('department', 'process_engineering')->random()->name, 'quality_assurance' => $employee->where('department', 'quality_assurance')->random()->name, 'other_department' => $employee->where('department', 'other_department')->random()->name, 'status' => 'Closed', 'created_at' => $info->created_at]); } }
public function processCalendar() { $date = Carbon::parse(Input::get('month')); return Redirect::route('calendar', array('year' => $date->year, 'month' => $date->month)); }
/** * @return timestamp */ public function getDeletedAtAttribute() { return \Carbon::parse($this->attributes['deleted_at'])->timestamp; }
<div class="row"> <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center"> <p>Pesanan Anda telah kami terima dengan nomor pesanan <strong>#{{ $data['order']['ref_number'] }}</strong> dengan nominal yang harus dibayarkan <strong>@money_indo( $data['order']['bills'] )</strong>.</p> <?php $due_date = Carbon::parse($data['order']['transact_at'])->addDay(); ?> <p>Email tagihan akan dikirimkan ke alamat email Anda, harap melakukan pembayaran sebelum tanggal <strong>@datetime_indo_with_name_month( $due_date )</strong>.</p> <p> </p> <p>Pembayaran dilakukan melalui transfer ke rekening : </p> <p>{!! $balin['info']['bank_information']['value'] !!}</p> <p> </p> <p><small><i>Anda dapat melihat pesanan anda di menu pribadi (Bagian Informasi Pengiriman & Tracking Order). <br>Lihatlah tagihan anda, yang kami kirimkan ke alamat email Anda.</i></small></p> </div> </div>
////////////// // Business // ////////////// $factory->define('App\\Models\\Business', function (Faker\Generator $faker) { return ['name' => $faker->sentence(3), 'description' => $faker->paragraph, 'timezone' => $faker->timezone, 'postal_address' => $faker->address, 'phone' => null, 'social_facebook' => 'https://www.facebook.com/example?fref=ts', 'strategy' => 'dateslot', 'plan' => 'free', 'category_id' => $faker->randomElement([1, 2, 3])]; }); ///////////// // Service // ///////////// $factory->define('App\\Models\\Service', function (Faker\Generator $faker) { return ['business_id' => factory(App\Models\Business::class)->create()->id, 'name' => $faker->sentence(2), 'description' => $faker->paragraph, 'prerequisites' => $faker->paragraph, 'duration' => $faker->randomElement([15, 30, 60, 120])]; }); ///////////// // Vacancy // ///////////// $factory->define('App\\Models\\Vacancy', function (Faker\Generator $faker) { $date = $faker->dateTimeBetween('today', 'today +7 days')->format('Y-m-d'); return ['business_id' => factory(App\Models\Business::class)->create()->id, 'service_id' => factory(App\Models\Service::class)->create()->id, 'date' => date('Y-m-d', strtotime($date)), 'start_at' => date('Y-m-d 00:00:00', strtotime($date)), 'finish_at' => date('Y-m-d 23:00:00', strtotime($date)), 'capacity' => 1]; }); ///////////////// // Appointment // ///////////////// $factory->define('App\\Models\\Appointment', function (Faker\Generator $faker) { return ['business_id' => factory(App\Models\Business::class)->create()->id, 'contact_id' => factory(App\Models\Contact::class)->create()->id, 'service_id' => factory(App\Models\Service::class)->create()->id, 'vacancy_id' => factory(App\Models\Vacancy::class)->create()->id, 'status' => $faker->randomElement(['R', 'C', 'A', 'S']), 'start_at' => Carbon::parse(date('Y-m-d 08:00:00', strtotime('today +2 days'))), 'duration' => $faker->randomElement([15, 30, 60, 120]), 'comments' => $faker->sentence]; }); //////////// // Domain // //////////// $factory->define('App\\Models\\Domain', function ($faker) { return ['slug' => str_slug($faker->name), 'owner_id' => factory(App\Models\User::class)->create()->id]; });
/** * Display a listing of the resource. * * @return \Illuminate\Http\JsonResponse * * @SWG\Get( * summary="Get all missions and the observations contributed by users", * path="/missions/observations", * description="Get all missions and the ovservations contributed by users.", * operationId="api.missions.observations", * produces={"application/json"}, * tags={"missions"}, * @SWG\Parameter( * name="from", * description="Limit to observations created at the date provided or later. Format: dd-mm-yyyy or mm/dd/yyyy", * required=false, * type="string", * in="query" * ), * @SWG\Parameter( * name="to", * description="Limit to observations created at the date provided or earlier. Format: dd-mm-yyyy or mm/dd/yyyy", * required=false, * type="string", * in="query" * ), * @SWG\Response( * response=200, * description="Returns all the missions of the application with their observations", * @SWG\Schema( * type="array", * @SWG\Items(ref="#/definitions/mission") * ), * ), * @SWG\Response( * response=400, * description="Unauthorized action", * ) * ) */ public function withObservations() { $from = null; $to = null; if (\Request::has('from')) { $from = date('Y-m-d', strtotime(\Request::get('from'))); } if (\Request::has('to')) { $to = date('Y-m-d', strtotime(\Request::get('to'))); } $missions = Mission::with('type', 'devices.observations')->get(); if ($from != null || $to != null) { $from = \Carbon::parse($from == null ? '01-01-1990' : $from); $to = \Carbon::parse($to == null ? '01-01-3000' : $to); foreach ($missions as $mid => $mission) { foreach ($mission->devices as $did => $device) { foreach ($device->observations as $oid => $observation) { if ($from->gt($observation->created_at) || $to->lt($observation->created_at)) { unset($device->observations[$oid]); } } if (count($device->observations) == 0) { unset($mission->devices[$did]); } } if (count($mission->devices) == 0) { unset($missions[$mid]); } } } $response = new ApiResponse(); $response->status = 'success'; $response->message = ['missions' => $missions]; return \Response::json($response); }
public function clientBookingStep1() { $i = Input::all(); if (Input::has('checkin') && Input::has('checkout')) { $checkin = Carbon::parse(Input::get('checkin')); $checkout = Carbon::parse(Input::get('checkout')); if ($checkin->gte($checkout)) { return Redirect::to('booking')->with('error', 'Check-out date must be greater than Check-in date.'); } Session::put('reservation.checkin', $i['checkin']); Session::put('reservation.checkout', $i['checkout']); Session::put('reservation.display_checkout', $i['checkout']); return Redirect::to('booking/step2'); } }
public function setLastUpdateAttribibute($date) { //$this->attributes['lastupdate'] = Carbon::createfromformat('d/m/Y H:i:s',$date); $this->attributes['lastupdate'] = Carbon::parse($date); }
public function getCreatedAtStrAttribute() { $created_at = Carbon::parse($this->created_at); return $created_at->diffForHumans(); }
public function getScore() { $seconds = $this->created_at->diffInSeconds(\Carbon::parse('2016-09-01')); $comments = $this->comments()->count(); $points = $comments / 2 + $this->ups - $this->downs; if ($points < -1) { $points = 1; } elseif ($points > -1 and $points < 1) { $points = 1; } if ($points < 0) { $sign = -1; } elseif ($points > 0) { $sign = 1; } else { $sign = 0; } $order = log($points); return round($sign * $order + $seconds / 45000, 7); }
private function exportnew() { $fecha = Input::get('invoice_date'); $dt = Carbon::parse($fecha); $month = $dt->month; $year = $dt->year; $fechaSearch = $month . "/" . $year; $output = fopen('php://output', 'w') or Utils::fatalError(); header('Content-Type:application/csv'); header('Content-Disposition:attachment;filename=Libro_Ventas.csv'); $BookSale = DB::table('book_sales')->select('invoice_date', 'invoice_number', 'number_autho', 'status', 'client_nit', 'client_name', 'amount', 'ice_amount', 'export_amount', 'grav_amount', 'subtotal', 'disc_bonus_amount', 'base_fiscal_debit_amount', 'fiscal_debit_amount', 'control_code')->where('account_id', '=', Auth::user()->account_id)->where('invoice_date', 'LIKE', '%' . $fechaSearch)->orderBy('invoice_date', 'asc')->get(); AccountController::exportBooksale($output, Utils::toArray($BookSale)); fclose($output); exit; }
public function getObtenerCorrectivos() { if (Request::ajax()) { $fecha_inicio = Input::get('fecha_inicio'); $fecha_fin = Input::get('fecha_fin'); $correctivos = DB::select("SELECT m.fecha_realizacion,a.num_activo,a.nombre,a.marca,a.modelo,a.serie,m.realizado_por,m.aprobado_por,a.costo from mantenimientos m, activos a where m.id_tipo_mantenimiento = 2 and a.id = m.id_activo AND m.fecha_realizacion BETWEEN '" . $fecha_inicio . "' AND '" . $fecha_fin . "' order by m.costo_mantenimiento desc"); $arrCorrectivo = json_decode(json_encode($correctivos), true); $cantidad = count($arrCorrectivo); for ($x = 0; $x < $cantidad; $x++) { array_set($arrCorrectivo[$x], 'fecha_realizacion', Carbon::parse($arrCorrectivo[$x]['fecha_realizacion'])->formatLocalized('%#d %b %Y')); } return Response::json($arrCorrectivo); } else { App::abort(403); } }
function setDateModification($dateModification) { $this->attributes['updated_at'] = Carbon::parse($dateModification); }
public function getCreate_atDate() { return Carbon::parse($this->attributes['created_at']); }
public function printpdf($id) { $data['active'] = 'stpd'; $data['stpd'] = STPD::find($id); $day = Carbon::parse($data['stpd']->tanggal_stpd); $berangkat = Carbon::parse($data['stpd']->tanggal_berangkat); $kembali = Carbon::parse($data['stpd']->tanggal_kembali); $data['day'] = $day; $data['hari'] = $kembali->diffInDays($berangkat) + 1; $pdf = PDF::loadView('templatesurat.STPD', $data); return $pdf->stream(); }
public function statNumbers($data) { $datemonth = date('M Y', time()); $firstday = Carbon::parse('first day of ' . $datemonth); $lastday = Carbon::parse('last day of ' . $datemonth)->addHours(23)->addMinutes(59)->addSeconds(59); $qval = array('$gte' => new MongoDate(strtotime($firstday->toDateTimeString())), '$lte' => new MongoDate(strtotime($lastday->toDateTimeString()))); $qc = array(); $qc['adId'] = $data['_id']; $qc['clickedAt'] = $qval; $qv = array(); $qv['adId'] = $data['_id']; $qv['viewedAt'] = $qval; $clicks = Clicklog::whereRaw($qc)->count(); $views = Viewlog::whereRaw($qv)->count(); return $clicks . ' clicks<br />' . $views . ' views'; }
/** * @test */ public function it_prevents_a_reservation_without_vacancy_with_timeslot() { $user = $this->createUser(); $this->actingAs($user); $business = $this->createBusiness(['name' => 'tosto this tosti', 'strategy' => 'timeslot']); $service = $this->makeService(); $business->services()->save($service); $contact = $this->makeContact($user); $business->contacts()->save($contact); $this->vacancy = $this->makeVacancy(['business_id' => $business->id, 'service_id' => $service->id, 'start_at' => Carbon::parse('today 08:00 ' . $business->timezone)->timezone('utc'), 'finish_at' => Carbon::parse('today 22:00 ' . $business->timezone)->timezone('utc'), 'capacity' => 1]); $this->vacancy->service()->associate($service); $business->vacancies()->save($this->vacancy); $otherDayThanVacancy = $this->vacancy->start_at->addDays(7)->timezone($business->timezone)->toDateString(); $this->withoutMiddleware(); $this->call('POST', route('user.booking.store', ['business' => $business]), ['businessId' => $business->id, 'service_id' => $service->id, '_time' => '09:00:00', '_date' => $otherDayThanVacancy, 'comments' => 'this is an invalid request']); $this->dontSeeInDatabase('appointments', ['business_id' => $business->id]); }