本文整理汇总了PHP中Room::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Room::orderBy方法的具体用法?PHP Room::orderBy怎么用?PHP Room::orderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Room
的用法示例。
在下文中一共展示了Room::orderBy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rooms
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]);
}
示例2: getIndex
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));
}
示例3: store
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);
}