本文整理汇总了PHP中app\Event::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Event::orderBy方法的具体用法?PHP Event::orderBy怎么用?PHP Event::orderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Event
的用法示例。
在下文中一共展示了Event::orderBy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: welcome
/**
* Shows the homepage.
*
* @return \Illuminate\Http\Response
*/
public function welcome()
{
//Gets a list of all events in a random order.
$randEvent = Event::orderBy(DB::raw('RAND()'))->get();
//returns the welcome view with the array of events from above.
return view('welcome', ['randEvent' => $randEvent]);
}
示例2: store
public function store(Request $request)
{
// Add new event
$event = new Event();
$event->name = $request->input('name');
$event->date = $request->input('date');
$this->selectVenue($request->input('venue'), $event);
$event->save();
//generate the filename
$file_name = strtolower($event->id . '-' . $event->venue->slug . '-' . date_format($event->date, 'd-m-y'));
// move the file
if ($request->file('image')) {
// resize and save
$image = Image::make($request->file('image'));
$image->resize(300, null, function ($constraint) {
$constraint->aspectRatio();
})->save(base_path() . '/public/img/posters/tn_' . $file_name);
// save full sized also
$request->file('image')->move(base_path() . '/public/img/posters/', $file_name);
}
// reselect the event..
$event = Event::orderBy('created_at', 'desc')->first();
if ($request->file('image')) {
// add the image and save it
$event->image = $file_name;
}
$event->save();
if (isset($request['bands'])) {
foreach ($request['bands'] as $band) {
$band = Band::where('name', $band)->first();
$event->band()->attach($band->id);
}
}
return redirect()->back();
}
示例3: index
public function index()
{
// Retrieve all events from the database
// and order by earliest starting first
$events = Event::orderBy('start_datetime', 'ASC')->get();
//return the view of all events
return view('events.index', ['events' => $events]);
}
示例4: dashboard
public function dashboard()
{
$venues = Venue::orderBy('name', 'asc')->get();
$bands = Band::orderBy('name', 'asc')->get();
$events = Event::orderBy('date', 'asc')->get();
$events_future = Event::futureEvents();
$events_past = Event::pastEvents();
return view('dashboard', compact('venues', 'events', 'events_future', 'events_past', 'bands'));
}
示例5: agenda
public function agenda()
{
$events = Event::orderBy('endtime')->get();
$pastevents = $events->filter(function ($item) {
return $item->starttime->isPast();
});
$futureevents = $events->filter(function ($item) {
return $item->starttime->isFuture();
});
return view('pages.public.agenda', compact('pastevents', 'futureevents', 'events'));
}
示例6: index
/**
* Show the admin dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//Gets all the event details from the event table
$events = Event::orderBy('created_at', 'desc')->paginate(5, ['*'], 'events');
$pastevents = Event::onlyTrashed()->orderBy('deleted_at', 'desc')->paginate(5, ['*'], 'past');
//gets all messages from the messages table
$messages = Message::join('users', 'users.id', '=', 'messages.userid')->select('users.name', 'users.email', 'messages.*')->whereNull('deleted_at')->orderBy('created_at', 'desc')->paginate(5, ['*'], 'messages');
//gets all the read (deleted) messages from the messags table.
$readMessages = Message::join('users', 'users.id', '=', 'messages.userid')->select('users.name', 'users.email', 'messages.*')->whereNotNull('deleted_at')->onlyTrashed()->orderBy('created_at', 'desc')->paginate(5, ['*'], 'read');
//Returns the events view along with the $events, $messages and $readMessages arrays containing the query results from above
return view('admin/admin', ['events' => $events, 'pastevents' => $pastevents, 'messages' => $messages, 'readMessages' => $readMessages]);
}
示例7: index
public function index(Request $request)
{
if (!Auth::check()) {
return response()->json($this->notLoginJson, 401);
} else {
$user = Auth::user();
if (!$user->hasRole('user')) {
return response()->json($this->needPermissionsJson, 401);
}
}
$events = Event::orderBy('date', 'desc')->get();
foreach ($events as $event) {
$event->load('members');
$event->loadResources();
}
return response()->json($events);
}
示例8: update
public function update(Request $request, $id)
{
if ($request->isMethod('get')) {
$this->data['items'] = Event::orderBy('created_at', 'asc')->get();
$this->data['questions'] = Question::get();
$this->data['lala'] = Event::find($id);
if ($this->data['lala']) {
return view('pages.event.update', $this->data);
} else {
return redirect('event');
}
} elseif ($request->isMethod('post')) {
$event = Event::find($id);
$event->update($request->all());
$event->question()->detach();
if (isset($request->all()['questions'])) {
$event->question()->sync($request->all()['questions']);
}
return redirect('event/detail/' . $id);
}
}
示例9: adminIndex
/**
* Display a listing of the resource.
*
* @return Response
*/
public function adminIndex()
{
$events = Event::orderBy('name')->with('bands', 'manager', 'article')->paginate(15);
return view('admin.events.index', compact('events'));
}
示例10: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$events = Event::orderBy('id', 'DESC')->get();
return view('events.index', compact('events'));
}
示例11: index
public function index()
{
$events = Event::orderBy('event_time')->upcoming()->get();
return view('events.all', compact('events'));
}
示例12: index
/**
* Show the application dashboard to the user.
*
* @return Response
*/
public function index()
{
$events = Event::orderBy('when', 'asc')->get();
return view('home', compact('events'));
}
示例13: index
public function index()
{
//
$events = Event::orderBy('created_at', 'DESC')->paginate(20);
return view('admin.event.index', compact('events'));
}
示例14: homepage
public function homepage()
{
$events = Event::orderBy('event_time')->get();
return View::make('home', compact('events'));
}
示例15: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$events = Event::orderBy('endtime')->get();
return view('pages.admin.events.index', compact('events'));
}