示例#1
0
文件: Tag.php 项目: suzumi/giita
 /**
  * 金曜日になると今週の週報タグを生成する
  */
 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  VoteWasOpened $event
  * @return void
  */
 public function handle(VoteWasOpened $event)
 {
     /**
      * Queue OpenVoteCommand
      */
     $command = new CloseVotingCommand($event->vote);
     $delay = $event->vote->close_date->timestamp - $this->carbon->now()->timestamp;
     $this->queue->laterOn('voting', $delay, $command);
 }
示例#3
0
 /**
  * @param $participants
  * @param $conversation_id
  * @return \Illuminate\Database\Eloquent\Model|static
  */
 public function addPartecipants($participants, $conversation_id)
 {
     $partecipantsConversartion = [];
     if (count($participants) > 1) {
         foreach ($participants as $key => $partecipant) {
             $partecipantsConversartion[$key] = ['conversation_id' => (int) $conversation_id, 'participant_id' => $partecipant, 'created_at' => $this->carbon->now(), 'updated_at' => $this->carbon->now()];
         }
         $multiPartecipants = true;
     } else {
         $partecipantsConversartion = ['conversation_id' => $conversation_id, 'participant_id' => $participants[0]];
         $multiPartecipants = false;
     }
     return $this->convJoinedRepo->add($partecipantsConversartion, $multiPartecipants);
 }
示例#4
0
 /**
  * Store a newly created Image in storage.
  *
  * @return Response
  */
 public function store()
 {
     // $a = '>>>|';
     // foreach (Request::all() as $key => $value) $a .=  $key . ':::' . $value . '|';
     // return $a;
     $valid_ext = ['jpg', 'png', 'bmp', 'gif', 'jpeg'];
     if (!Request::hasFile('image')) {
         throw new FileUploadException('image not found');
     }
     if (!Request::file('image')->isValid()) {
         throw new FileUploadException('image is not valid');
     }
     $params = Request::all();
     $file = $params['image'];
     unset($params['image']);
     if (!in_array($file->getClientOriginalExtension(), $valid_ext)) {
         throw new FileUploadException('image type is not valid');
     }
     $file_name = Carbon::now()->format('Ymd_His_') . $params['title'] . '.' . $file->getClientOriginalExtension();
     $file_path = 'images/';
     $params['filename'] = $file_name;
     $image = new Image($params);
     if ($image->save()) {
         Storage::put($file_path . $file_name, File::get($file));
         return $image;
     } else {
         throw new CrudException('image:store');
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index($userId)
 {
     $user = User::find($userId);
     $runningtimes = User::find($userId)->runningtimes()->orderBy('ran_on', 'desc')->get();
     $total_km = 0;
     $total_time = 0;
     foreach ($runningtimes as $rt) {
         $total_km += $rt['distance'];
     }
     $total_km = sprintf('%05.2f', $total_km);
     $av_speed = sprintf('%05.2f', User::find($userId)->runningtimes()->avg('speed'));
     $dt = Carbon::now()->subMonths(1);
     $good_speeds = 0;
     $c = 0;
     foreach ($runningtimes as $rt) {
         if ($rt['ran_on']->gt($dt) and $rt['ran_on']->lte(Carbon::now())) {
             $good_speeds += $rt['speed'];
             $c += 1;
         }
     }
     if ($c > 0) {
         $av_speed_month = sprintf('%05.2f', $good_speeds / $c);
     } else {
         $av_speed_month = sprintf('%05.2f', 0);
     }
     return view('runningtimes.index', ['user' => $user, 'runningtimes' => $runningtimes, 'total_km' => $total_km, 'av_speed' => $av_speed, 'av_speed_month' => $av_speed_month]);
 }
示例#6
0
 public function __construct()
 {
     $this->middleware('ipblocked');
     $driver = config('database.default');
     $database = config('database.connections');
     $this->db = $database[$driver]['database'];
     $this->dbuser = $database[$driver]['username'];
     $this->dbpass = $database[$driver]['password'];
     $this->dbhost = $database[$driver]['host'];
     if (\Auth::check() == true) {
         if (!\Session::get('gid')) {
             \Session::put('uid', \Auth::user()->id);
             \Session::put('gid', \Auth::user()->group_id);
             \Session::put('eid', \Auth::user()->email);
             \Session::put('ll', \Auth::user()->last_login);
             \Session::put('fid', \Auth::user()->first_name . ' ' . \Auth::user()->last_name);
             \Session::put('themes', 'sximo-light-blue');
         }
     }
     if (!\Session::get('themes')) {
         \Session::put('themes', 'sximo');
     }
     if (defined('CNF_MULTILANG') && CNF_MULTILANG == 1) {
         $lang = \Session::get('lang') != "" ? \Session::get('lang') : CNF_LANG;
         \App::setLocale($lang);
     }
     $data = array('last_activity' => strtotime(Carbon::now()));
     \DB::table('tb_users')->where('id', \Session::get('uid'))->update($data);
 }
 /**
  * 成績資料.
  *
  * @param Request $request
  * @return array
  */
 protected function grades(Request $request)
 {
     $key = 'grades-' . md5($request->user()->getAuthIdentifier()) . '-' . $this->courseId;
     return Cache::tags('ecourse-lite')->remember($key, Carbon::now()->endOfDay(), function () {
         return Grade::lists($this->courseId);
     });
 }
示例#8
0
 /**
  * Store a newly created book in storage.
  *
  * @param  BookRequest  $request
  * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse
  */
 public function store(BookRequest $request)
 {
     $this->book->create($request);
     event(new BookHasCreated('Δημιουργία βιβλίου: ' . $request->title, Carbon::now()->format('Y-m-d'), 'http://library.gr/cPanel/unpublished/' . $request->get('barcode') . '/confirm', $this->user->myAdministratorHash(), $request->get('barcode'), 1));
     flash()->overlay('Συγχαρητήρια', 'το βιβλίο ' . $request->title . ' δημιουργήθηκε με επιτυχία. Αναμένετε έγκριση από τον διαχειριστή');
     return redirect()->back();
 }
 public function postPayment()
 {
     // Step 1: Check if the request contains required fields
     if (!$this->validatePaymentRequest()) {
         $this->response->addMessage('Invalid Payment Request.');
         return $this->output();
     }
     // Step 2: Validation passed -> Create new payment
     $payment = new \Payment();
     $payment->payment_amount_ex_vat = $this->data['payment_amount_ex_vat'];
     $payment->vat_amount = $this->data['vat_amount'];
     $payment->gratuity_amount = isset($this->data['gratuity_amount']) ? $this->data['gratuity_amount'] : 0;
     $payment->branch_id = $this->data['branch_id'];
     $payment->payment_vendor_id = $this->data['payment_vendor_id'];
     $payment->employee_id = $this->data['employee_id'];
     $payment->order_id = $this->data['order_id'];
     $payment->payment_taken_at = $this->data['payment_taken_at'];
     $payment->terminal_id = $this->data['terminal_id'];
     $payment->created_at = \Carbon\Carbon::now();
     // Step 3: Save the payment into the database
     if ($payment->save()) {
         $this->response->setSuccess(1);
         $this->response->setPaymentId($payment->id);
         return $this->output();
     }
 }
示例#10
0
 /**
  * Show the application dashboard.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $today = Carbon::today();
     $tomorrow = Carbon::tomorrow();
     $tomorrowbookinguser = Booking::where('bookingdate', '=', $tomorrow)->get();
     $dt = Carbon::now();
     $year = $dt->year;
     $month = $dt->month;
     $currentmonthbreakfast = Booking::where('user_id', Auth::user()->id)->whereMonth('bookingdate', '=', $month)->whereYear('bookingdate', '=', $year)->where('breakfast', '=', 'on')->count();
     $currentmonthlunch = Booking::where('user_id', Auth::user()->id)->whereMonth('bookingdate', '=', $month)->whereMonth('bookingdate', '=', $month)->whereYear('bookingdate', '=', $year)->where('lunch', '=', 'on')->count();
     $currentmonthdinner = Booking::where('user_id', Auth::user()->id)->whereMonth('bookingdate', '=', $month)->whereMonth('bookingdate', '=', $month)->whereYear('bookingdate', '=', $year)->where('dinner', '=', 'on')->count();
     $totalbooking = $currentmonthbreakfast + $currentmonthlunch + $currentmonthdinner;
     $price = Account::whereMonth('accountdate', '=', date('m'))->where('user_id', Auth::user()->id)->sum('amount');
     $todaydayshop = Shop::where('shopdate', $today)->get();
     $tomorrowshop = Shop::where('shopdate', $tomorrow)->get();
     $bookings = Booking::where('bookingdate', '=', $today)->get();
     $breakfast = Booking::where('bookingdate', '=', $today)->where('breakfast', '=', 'on')->count();
     $lunch = Booking::where('bookingdate', '=', $today)->where('lunch', '=', 'on')->count();
     $dinner = Booking::where('bookingdate', '=', $today)->where('dinner', '=', 'on')->count();
     $t_breakfast = Booking::where('bookingdate', '=', $tomorrow)->where('breakfast', '=', 'on')->count();
     $t_lunch = Booking::where('bookingdate', '=', $tomorrow)->where('lunch', '=', 'on')->count();
     $t_dinner = Booking::where('bookingdate', '=', $tomorrow)->where('dinner', '=', 'on')->count();
     $useraccounts = DB::table('useraccounts')->where('user_id', Auth::user()->id)->select('user_id', DB::raw("SUM(foodamount) AS t_foodamount"), DB::raw("SUM(houserent) AS t_houserent"), DB::raw("SUM(internetbill) AS t_internetbill"), DB::raw("SUM(utlitybill) AS t_utlitybill"), DB::raw("SUM(buabill) AS t_buabill"), DB::raw("SUM(pay) AS t_pay"))->get();
     foreach ($useraccounts as $account) {
         $amount = $account->t_foodamount + $account->t_houserent + $account->t_internetbill + $account->t_utlitybill + $account->t_buabill;
         $balance = $amount - $account->t_pay;
     }
     return view('home', ['bookings' => $bookings, 'breakfast' => $breakfast, 'lunch' => $lunch, 'dinner' => $dinner, 't_breakfast' => $t_breakfast, 't_lunch' => $t_lunch, 't_dinner' => $t_dinner, 'tomorrow' => $tomorrow, 'todaydayshop' => $todaydayshop, 'tomorrowshop' => $tomorrowshop, 'tomorrowbookinguser' => $tomorrowbookinguser, 'balance' => $balance, 'currentmonthbreakfast' => $currentmonthbreakfast, 'currentmonthlunch' => $currentmonthlunch, 'currentmonthdinner' => $currentmonthdinner, 'totalbooking' => $totalbooking, 'price' => $price]);
 }
 public function run()
 {
     DB::table('readings')->delete();
     Reading::create(array('device' => 1, 'temp' => 19.5, 'heaton' => 1, 'created_at' => \Carbon\Carbon::now()->subDays(2)->toDateTimeString(), 'updated_at' => \Carbon\Carbon::now()->subDays(2)->toDateTimeString()));
     Reading::create(array('device' => 1, 'temp' => 19.7, 'heaton' => 1, 'created_at' => \Carbon\Carbon::now()->subDays(1)->toDateTimeString(), 'updated_at' => \Carbon\Carbon::now()->subDays(1)->toDateTimeString()));
     Reading::create(array('device' => 1, 'temp' => 20.1, 'heaton' => 0, 'created_at' => \Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => \Carbon\Carbon::now()->toDateTimeString()));
 }
 public function run()
 {
     DB::statement("SET foreign_key_checks = 0");
     DB::table('rewards')->delete();
     $rewards = [['num_referrals' => 0, 'title' => 'Two Weeks Free', 'description' => 'Sign up to receive two weeks for free', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()], ['num_referrals' => 1, 'title' => 'Additional Two Weeks Free', 'description' => 'Refer 1 friends for an additional two weeks for free', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()], ['num_referrals' => 3, 'title' => 'Additional Month Free', 'description' => 'Refer 3 or more friends for an additional month for free', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]];
     DB::table('rewards')->insert($rewards);
 }
示例#13
0
 public static function customCreate(CreateConversationRequest $request)
 {
     $conv = new Conversation();
     $conv->Title = $request->Title;
     // if nothing specified in the request
     if (!$request->has('user_id')) {
         // if we are not even logged ( happen while seeding base)
         if (!\Auth::check()) {
             $conv->user_id = User::first()->id;
         } else {
             $conv->user_id = \Auth::id();
         }
     }
     // if Pending status is specified we take it, if not default value will be applied (false)
     if (!$request->has('Pending')) {
         $conv->Pending = $request->Pending;
     }
     $conv->created_at = Carbon::now();
     $conv->save();
     // When conversation is settled the Thread can be created
     $thread = new Thread();
     $thread->user_id = $conv->user_id;
     $thread->Content = $request->Content;
     $thread->conversation_id = $conv->id;
     $thread->created_at = Carbon::now();
     $thread->Pending = $conv->Pending;
     $thread->save();
     return true;
 }
示例#14
0
 /**
  * Insert reaction in DB (eiter from a Facebook post or Tweet)
  * @param  string $type
  * @param  object $mention
  * @param  integer $id
  * @param  string $answer
  *
  * @return Reaction
  */
 public function insertReaction($type, $mention, $id, $answer = null)
 {
     $reaction = new Reaction();
     $reaction->publishment_id = $id;
     if ($answer != null) {
         $reaction->user_id = Auth::user()->id;
     }
     if ($type == 'twitter') {
         if ($mention['user']['id_str'] != Configuration::twitterId()) {
             $reaction->user_id = $mention['user']['id_str'];
         }
         $reaction->screen_name = $mention['user']['screen_name'];
         $reaction->tweet_id = $mention['id_str'];
         $reaction->tweet_reply_id = $mention['in_reply_to_status_id_str'];
         $reaction->message = $mention['text'];
         $reaction->post_date = changeDateFormat($mention['created_at']);
     } else {
         $reaction->fb_post_id = $mention->id;
         if ($answer == null) {
             $reaction->screen_name = $mention->from->name;
             $reaction->message = $mention->message;
             $reaction->post_date = changeFbDateFormat($mention->created_time);
         } else {
             $reaction->message = $answer;
             $reaction->post_date = Carbon::now();
         }
     }
     $reaction->save();
     return $reaction;
 }
示例#15
0
 /**
  * Write data to file
  *
  * @param array $data
  * @return bool|int|void
  */
 public function putContent($data)
 {
     if (file_put_contents($this->getFilePath(), $data)) {
         $this->setUpdatedAt(Carbon::now()->toDateTimeString());
     }
     return $this->save();
 }
示例#16
0
 public function edit(Article $article)
 {
     $tags = Tag::lists("name", "id");
     $published_at = Carbon::now();
     $usert = $article->getTagListAttribute();
     return view('articles.edit', compact('article', 'usert', 'published_at', 'tags'));
 }
 /**
  * Create a new command instance.
  *
  * @param Carbon     $carbon
  * @param Dispatcher $dispatcher
  * @param Log        $log
  */
 public function __construct(Carbon $carbon, Dispatcher $dispatcher, Log $log)
 {
     parent::__construct();
     $this->now = $carbon->now();
     $this->dispatcher = $dispatcher;
     $this->log = $log;
 }
示例#18
0
 /**
  * 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');
 }
示例#19
0
 public function terkini()
 {
     $bil = 1;
     $laporans = Laporan::where('tarikh', 'like', Carbon::now()->format('Y-m') . '%')->where('user', Auth::user()->username)->get();
     //        dd($laporans);
     return View('members.technician.laporan.terkini', compact('bil', 'laporans'));
 }
 public function testGetTtlInSecondsException()
 {
     $now = Carbon::now();
     $this->setExpectedException(Exception::class);
     TimeTools::getTtlInSeconds($now->subMinute(2));
     $this->setExpectedException(Exception::class);
 }
示例#21
0
 public function updateLaboratorio(Request $request)
 {
     $permiso = DB::table('usuario')->join('rol', 'usuario.rol_id', '=', 'rol.id')->join('rol_permiso', 'rol_permiso.rol_id', '=', 'rol.id')->join('permiso', 'rol_permiso.permiso_id', '=', 'permiso.id')->select('permiso.id')->where('permiso.id', '10')->where('usuario.id', Auth::user()->id)->count();
     if ($permiso < 1) {
         return Response::json(array('Success' => 'false'));
         //return redirect()->route('/');
     }
     $id = $request->input('idLaboratorio');
     $nombre = $request->input('nameLaboratorio');
     $direccion = $request->input('descriptionLaboratorio');
     $correo = $request->input('correoLaboratorio');
     $telefonos = $request->input('telefonoLaboratorio');
     $user_created = Auth::user()->username;
     $estadoM = $request->input('estadoLaboratorio');
     $date = Carbon::now();
     $exists = DB::table('laboratorio')->select('nombre')->where('nombre', $nombre)->whereNotIn('id', array($id))->count();
     if ($exists > 0) {
         return Response::json(array('Success' => 'false'));
     }
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     DB::table('laboratorio')->where('id', '=', $id)->update(array('nombre' => $nombre, 'direccion' => $direccion, 'correo' => $correo, 'user_updated' => $user_created, 'estado' => $estadoM, 'updated_at' => $date));
     DB::table('telefonoLaboratorio')->where('laboratorio_id', $id)->delete();
     foreach ($telefonos as $telefono) {
         DB::table('telefonoLaboratorio')->insert(array('laboratorio_id' => $id, 'telefono' => $telefono, 'user_updated' => $user_created));
     }
     return Response::json(array('Success' => 'true'));
 }
 protected function create()
 {
     $route = Helpers::routeinfo();
     /*
     		$event 			= Conference::where('slug', '=', $route->params['conference'])
     									->published()
     									->latest();
     */
     $events = Lookup::lookup('conferences', [$route->params['conference']], ['latest' => true, 'published' => true]);
     $event = $events[0];
     $options = Helpers::unserialize($event->options);
     $options['speakers'] = false;
     $options['sponsors'] = false;
     $options['partners'] = false;
     $options = Helpers::options($route, $route->params['conference']);
     $newEvent = Conference::create(['slug' => $route->params['conference'], 'conference' => $event->conference, 'city' => $event->city, 'state' => $event->state, 'start_date' => Carbon::createFromFormat('Y-m-d H:i:s', $event->start_date)->addYear(), 'end_date' => Carbon::createFromFormat('Y-m-d H:i:s', $event->end_date)->addYear(), 'timezone' => $event->timezone, 'coming' => 1, 'about' => $event->about, 'tags' => $event->tags, 'options' => Helpers::serialize($options), 'hero' => $event->hero, 'photo' => $event->photo, 'published' => Carbon::now()]);
     $newEvent = (object) $newEvent->toArray();
     $newAgendas = [];
     $agendas = Lookup::lookup('agendas', ['conference' => $event->id], ['published' => true]);
     if (is_array($agendas)) {
         foreach ($agendas as $agenda) {
             $agenda->conference_id = $newEvent->id;
             $agenda->timeslot = Carbon::createFromFormat('Y-m-d H:i:s', $agenda->timeslot)->addYear();
             $agenda->title = $agenda->type === 'breakout' || $agenda->type === 'session' ? 'Breakout Session' : ($agenda->type === 'break' ? $agenda->title : 'Keynote');
             $agenda->title_short = $agenda->type === 'breakout' || $agenda->type === 'session' ? 'Breakout Session' : ($agenda->type === 'break' ? $agenda->title : 'Keynote');
             $agenda->subtitle = null;
             $agenda->desc = null;
             $agenda->speakers = null;
             $agenda->published = Carbon::now();
             $newAgendas[] = Agenda::create((array) $agenda);
         }
     }
     $container = (object) ['event' => (object) $newEvent, 'agendas' => (object) $newAgendas];
     dd($newEvent);
 }
示例#23
0
 /**
  * Convert to readable date
  *
  * @return int
  */
 public function created_at()
 {
     if (is_null($this->resource->created_at)) {
         return Carbon::now()->diffForHumans();
     }
     return $this->resource->created_at->diffForHumans();
 }
示例#24
0
 public function dashboard()
 {
     // METHODE ORM
     $nbacteurs = Actors::count();
     $nbcommentaire = Commentaire::count();
     $avgcommentaire = Commentaire::avg('note');
     $countnotepresse = Movies::count('note_presse');
     $avgnotepresse = Movies::avg('note_presse');
     $moviescount = Movies::count('id');
     $avgmovies = Movies::avg('duree');
     $actor = new Actors();
     //methode query builder
     $avgacteur = $actor->getAvgActors();
     $notepresse2 = new Movies();
     $countnotepresse2 = $notepresse2->getAvgNoteMovies();
     $avgsession = Sessions::count('id');
     $session = new Sessions();
     $sessionavg = $session->getAvgSession2();
     $lastuser = new User();
     $last = $lastuser->getLastUsers();
     // 15 prochaine (TROISIEME METHODE )
     $nextsession = Sessions::where('date_session', "<", Carbon::now())->take(15)->get();
     // premiere methode avec 2 jointures :
     $seance = new Sessions();
     $resultseance = $seance->getNextSession();
     $allcategories = Categories::all();
     $alldirectors = Directors::count('id');
     $distrib = new Movies();
     $distributeur = $distrib->countDistributeur();
     $villeacteur = new Actors();
     $villebyacteur = $villeacteur->getVilleByActors();
     // exit(dump($villebyacteur ));
     return view('Main/dashboard', ['nbacteurs' => $nbacteurs, 'nbcommentaire' => $nbcommentaire, 'avgacteur' => $avgacteur->age, 'avgcommentaire' => $avgcommentaire, 'avgnotepresse' => $avgnotepresse, 'countnotepresse' => $countnotepresse, 'moviescount' => $moviescount, 'avgmovies' => $avgmovies, 'countnotepresse2' => $countnotepresse2->note, 'avgsession' => $avgsession, 'sessionavg' => $sessionavg->date, 'last' => $last, 'nextsession' => $nextsession, 'allcategories' => $allcategories, 'alldirectors' => $alldirectors, 'distributeur' => $distributeur, 'villeacteur' => $villebyacteur]);
 }
 public function update(Request $request, $id)
 {
     $assignment = App\Assignment::findOrFail($id);
     $assignment->completed_at = Carbon::now();
     $assignment->save();
     return view('assignments.show', compact('assignment'));
 }
示例#26
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     for ($i = 0; $i < 20; $i++) {
         DB::table('stores')->insert([['brand_id' => rand(1, 10), 'payment_type' => rand(1, 3), 'store_name' => $faker->company . ' Store', 'address' => $faker->address, 'latitude' => $faker->latitude, 'longitude' => $faker->longitude, 'opening_time' => 10 + rand(1, 3), 'closing_time' => 20 + rand(1, 3), 'highlights' => 'Ready made', 'price_range' => 1000 + rand(100, 600) . '-' . (10000 + rand(1500, 1900)), 'created_at' => \Carbon\Carbon::now(), 'updated_at' => \Carbon\Carbon::now()]]);
     }
 }
示例#27
0
 /**
  * @param Model $claimer
  *
  * @return Model
  */
 public function claim(Model $claimer)
 {
     $this->claimer()->associate($claimer);
     $this->claimed_at = Carbon::now();
     $this->save();
     return $claimer;
 }
示例#28
0
 function deleting($model)
 {
     if ($model->launched_at->lt(\Carbon\Carbon::now())) {
         $model->setErrors(new MessageBag(['already_launched' => 'Live website cannot be deleted']));
         return false;
     }
 }
 /**
  * @param $user
  * @param $amount
  * @return void
  */
 private function setupNewMember(User $user, $amount)
 {
     //At this point the day of the month hasn't been set for the user, set it now
     $user->updateSubscription('paypal', Carbon::now()->day);
     //if this is blank then the user hasn't been setup yet
     $subCharge = $this->subscriptionChargeRepository->createCharge($user->id, Carbon::now(), $amount);
 }
示例#30
0
 public function calculator($product, $bypassUser = false, $custom = null)
 {
     // 1
     // First of all, we take regular price
     $price = $product['price'];
     // 2
     // We check if sales price exists and it's active
     if (Carbon::now() >= $product['price_sales_on'] && Carbon::now() <= $product['price_sales_off']) {
         $price = $product['price_sales'];
     }
     // 3
     // We check if we have logged user & if he has active discount
     if (app('auth')->id() <= 0 || $bypassUser == true) {
         return $this->currency($price, $product['currency'], $custom);
     }
     // 4
     // We check if existing user have discount
     $discounts = $this->discounts($price, $custom);
     if ($discounts['discount'] == true) {
         return $this->currency($discounts['price'], $product['currency'], $custom);
     }
     // 5
     // We check if existing user have discount by his role
     $discounts_by_role = $this->discounts_by_role($product, $price, $custom);
     if ($discounts_by_role['discount'] == true) {
         return $this->currency($discounts_by_role['price'], $product['currency'], $custom);
     }
     // if no discounts for user
     return $this->currency($price, $product['currency'], $custom);
 }