public function rooms() { Mate::where('created_at', '<', date('Y-m-d H:i:s', strtotime('-1 day')))->delete(); Room::where('created_at', '<', date('Y-m-d H:i:s', strtotime('-1 day')))->delete(); Room::where('created_at', '<', date('Y-m-d H:i:s', strtotime('-1 hour')))->where('state', 'LIKE', 'end%')->delete(); $rooms = Room::orderBy('created_at', 'DESC')->paginate(); return View::make('prepare.rooms', ['rooms' => $rooms]); }
public function getIndex() { $key = Input::get('search'); if (isset($key)) { $data = Room::where('name', 'like', '%' . $key . '%')->orderBy('id', 'desc')->paginate(10); } else { $data = Room::orderBy('id', 'desc')->paginate(10); } return View::make('home/dashboard', array())->nest('content', 'room/index', array('data' => $data)); }
public function store(Request $request) { $this->validate($request, ['name' => 'required', 'info' => 'required', 'rate' => 'required'], ['name.required' => 'Ange namn!']); Room::updateOrCreate(['id' => $request->submit], array('name' => $request->name, 'info' => $request->info, 'rate' => $request->rate)); $thisObject = Room::orderBy('updated_at', 'desc')->first(); if (!file_exists(public_path() . '/room/' . $thisObject->id . '/')) { mkdir(public_path() . '/room/' . $thisObject->id . '/', 0777, true); } if (Input::file('img')) { $image = Input::file('img'); $destinationPath = public_path() . '/room/' . $thisObject->id . '/'; $filename = $image->getClientOriginalName(); $image->move($destinationPath, $filename); } return redirect('rooms/' . $request->slug); }