/** * @param $date */ public function internalStore(Carbon $date) { $this->date = new Date(); if ($this->date->where('date', $date->format('Y-m-d'))->exists()) { } else { $this->generateDate($date); $this->date->save(); } }
/** * Run the database seeds. * * @return void */ public function run() { $date_id = \App\Date::where('date', '=', '2014-07-29')->pluck('id'); $country_id = \App\Country::where('country', '=', 'India')->pluck('id'); DB::table('images')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'filename' => '2014-07-29-1270.jpg', 'caption' => 'Keylong, 2014', 'narrative' => 'Out for a stroll with Vortex, north towards Leh', 'date_id' => $date_id, 'country_id' => $country_id]); $date_id = \App\Date::where('date', '=', '2014-07-23')->pluck('id'); $country_id = \App\Country::where('country', '=', 'India')->pluck('id'); DB::table('images')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'filename' => "2014-07-23-1045.jpg", 'caption' => 'Brian Neill, 2014', 'narrative' => 'Beautiful, remote, wonderful...', 'date_id' => $date_id, 'country_id' => $country_id]); $date_id = \App\Date::where('date', '=', '2013-06-10')->pluck('id'); $country_id = \App\Country::where('country', '=', 'India')->pluck('id'); DB::table('images')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'filename' => "2013-06-10-0928.jpg", 'caption' => 'A Monastery', 'narrative' => '', 'date_id' => $date_id, 'country_id' => $country_id]); $date_id = \App\Date::where('date', '=', '2014-07-23')->pluck('id'); $country_id = \App\Country::where('country', '=', 'India')->pluck('id'); DB::table('images')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'filename' => "2014-07-23-1015.jpg", 'caption' => 'Brian Neill, 2014', 'narrative' => 'Beautiful, remote, wonderful...', 'date_id' => $date_id, 'country_id' => $country_id]); $date_id = \App\Date::where('date', '=', '2013-06-09')->pluck('id'); $country_id = \App\Country::where('country', '=', 'India')->pluck('id'); DB::table('images')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'filename' => '2013-06-09-0871.jpg', 'caption' => 'Leh', 'narrative' => 'once upon a time....', 'date_id' => $date_id, 'country_id' => $country_id]); $date_id = \App\Date::where('date', '=', '2013-06-02')->pluck('id'); $country_id = \App\Country::where('country', '=', 'India')->pluck('id'); DB::table('images')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'filename' => '2013-06-02-0157.jpg', 'caption' => 'Indian Railways', 'narrative' => 'On the narrow-gauge line at Jogindernagar.', 'date_id' => $date_id, 'country_id' => $country_id]); $date_id = \App\Date::where('date', '=', '2013-06-07')->pluck('id'); $country_id = \App\Country::where('country', '=', 'India')->pluck('id'); DB::table('images')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'filename' => '2013-06-07-0712.jpg', 'caption' => 'Prayer Flags', 'narrative' => 'The view from my breakfast table.', 'date_id' => $date_id, 'country_id' => $country_id]); $date_id = \App\Date::where('date', '=', '2013-06-07')->pluck('id'); $country_id = \App\Country::where('country', '=', 'India')->pluck('id'); DB::table('images')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'filename' => '2013-06-07-0749.jpg', 'caption' => 'Prayer Flags', 'narrative' => '', 'date_id' => $date_id, 'country_id' => $country_id]); $date_id = \App\Date::where('date', '=', '2013-06-12')->pluck('id'); $country_id = \App\Country::where('country', '=', 'India')->pluck('id'); DB::table('images')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'filename' => '2013-06-12-1101.jpg', 'caption' => 'Village wall, wood and sky', 'narrative' => '', 'date_id' => $date_id, 'country_id' => $country_id]); $date_id = \App\Date::where('date', '=', '2013-06-14')->pluck('id'); $country_id = \App\Country::where('country', '=', 'India')->pluck('id'); DB::table('images')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'filename' => '2013-06-14-1448.jpg', 'caption' => 'The road up to the Khardung La', 'narrative' => 'Getting high', 'date_id' => $date_id, 'country_id' => $country_id]); $date_id = \App\Date::where('date', '=', '2013-06-15')->pluck('id'); $country_id = \App\Country::where('country', '=', 'India')->pluck('id'); DB::table('images')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'filename' => '2013-06-15-1607.jpg', 'caption' => 'Khardung Village', 'narrative' => '', 'date_id' => $date_id, 'country_id' => $country_id]); $date_id = \App\Date::where('date', '=', '2013-06-15')->pluck('id'); $country_id = \App\Country::where('country', '=', 'India')->pluck('id'); DB::table('images')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'filename' => '2013-06-15-1625.jpg', 'caption' => 'Khardung Village', 'narrative' => '', 'date_id' => $date_id, 'country_id' => $country_id]); $date_id = \App\Date::where('date', '=', '2013-06-16')->pluck('id'); $country_id = \App\Country::where('country', '=', 'India')->pluck('id'); DB::table('images')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'filename' => '2013-06-16-1701.jpg', 'caption' => 'Clearing skies, from my hotel balconey', 'narrative' => '', 'date_id' => $date_id, 'country_id' => $country_id]); $date_id = \App\Date::where('date', '=', '2013-06-16')->pluck('id'); $country_id = \App\Country::where('country', '=', 'India')->pluck('id'); DB::table('images')->insert(['created_at' => Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => Carbon\Carbon::now()->toDateTimeString(), 'filename' => '2013-06-16-1706.jpg', 'caption' => 'Sand dunes and scree, Hunder, Nubra Valley', 'narrative' => '', 'date_id' => $date_id, 'country_id' => $country_id]); }
/** * Execute the console command. * * @return mixed */ public function handle() { // \Log::info('I was here @' . Carbon::now() ); $thisDate = Date::where('endDate', '<', Carbon::now())->orderby('endDate', 'DESC')->first(); $competitors = Competitor::where('created_at', '>', $thisDate->startDate)->where('created_at', '<', $thisDate->endDate)->where('is_deleted', '=', false)->get(); if (!count($thisDate->winner) && count($competitors)) { // var_dump($competitors); $winner = $competitors->first(); foreach ($competitors as $competitor) { var_dump($competitor->getTotalVotes()); echo '</br>'; if ($competitor->getTotalVotes() > $winner->getTotalVotes()) { $winner = $competitor; } } $newWinner = new Winner(); $newWinner->competitor_id = $winner->id; $newWinner->date_id = $thisDate->id; $newWinner->save(); } }
public function test() { $thisDate = Date::where('endDate', '<', Carbon::now())->orderby('endDate', 'DESC')->first(); $competitors = Competitor::where('created_at', '>', $thisDate->startDate)->where('created_at', '<', $thisDate->endDate)->get(); if (!count($thisDate->winner) && count($competitors)) { // var_dump($competitors); $winner = $competitors->first(); foreach ($competitors as $competitor) { var_dump($competitor->getTotalVotes()); echo '</br>'; if ($competitor->getTotalVotes() > $winner->getTotalVotes()) { $winner = $competitor; } } $newWinner = new Winner(); $newWinner->competitor_id = $winner->id; $newWinner->date_id = $thisDate->id; $newWinner->save(); } // $thisDate = Date::where('endDate', '<', Carbon::now())->orderby('endDate', 'DESC')->first(); // var_dump($thisDate); // echo '</br>'; // if (count($thisDate->winner)) // { // echo 'er is reeds een winnaar'; // } else // { // echo 'er is nog geen winnaar'; // } }
public function calendar() { $days = array(); $bookings = Date::all(); $count = 0; foreach ($bookings as $booking) { $day = array('bind' => 0, 'price' => $booking->price, 'status' => $booking->status); $count++; $days[$booking->date] = $day; } return json_encode($days); }
public function search(Request $request) { // echo '<pre>'; // var_dump($request->all()); // return $request->input('date'); $dates = Date::all(); foreach ($dates as $date) { // var_dump($date->typeOfDate); } if ($request->input('type')) { $newDates = new \Illuminate\Database\Eloquent\Collection(); switch ($request->input('type')) { case 'culinair': foreach ($dates as $date) { if ($date->typeOfDate == "1") { $newDates->push($date); // = $dates->where('typeOfDate', "1"); } } break; case 'romantic': //$dates = $dates->where('typeOfDate', "2"); foreach ($dates as $date) { // echo $date->id; if ($date->typeOfDate == "2") { // var_dump('romantic'); $newDates->push($date); // = $dates->where('typeOfDate', "1"); } } break; } // var_dump($newDates); $dates = $newDates; } if ($request->input('date')) { $newDates = new \Illuminate\Database\Eloquent\Collection(); foreach ($dates as $date) { // echo $date->date; if ($date->date == $request->input('date')) { $newDates->push($date); } } $dates = $newDates; } if ($request->input('sex')) { $newDates = new \Illuminate\Database\Eloquent\Collection(); foreach ($dates as $date) { if ($date->host->sex == $request->input('sex')) { $newDates->push($date); } } $dates = $newDates; } foreach ($dates as $date) { // $date->host()->id; $date->host = $date->host()->first(); $date->host->pic = $date->host->pictures()->first(); } // var_dump($dates); return response()->json($dates); // $dates = Date::all(); // // $data = ['dates' => $dates]; // // var_dump($request->all()); // // var_dump($dates); // return view('dates.search')->with($data); }