laravel tips

Solutions on MaxInterview for laravel tips by the best coders in the world

showing results for - "laravel tips"
Noah
31 Jan 2021
1Route::get('orders', function()
2{
3    return View::make('orders.index')
4        ->with('orders', Order::all());
5});
6//@sujay
Carlos
22 Sep 2020
1Route::get('logout', function()
2{
3    Auth::logout();
4     
5    return Redirect::home();
6});
7//@sujay
Nicola
20 Sep 2016
1$q->where(function ($query) {
2    $query->where('gender', 'Male')
3        ->where('age', '>=', 18);
4})->orWhere(function($query) {
5    $query->where('gender', 'Female')
6        ->where('age', '>=', 65);
7})
8
9
Elliot
31 Jun 2017
1Article::find($article_id)->increment('read_count');
2Article::find($article_id)->increment('read_count', 10); // +10
3Product::find($produce_id)->decrement('stock'); // -1
4//@sujay
Maxime
03 Jul 2017
1{{ Form::model($order) }}
2    <div>
3        {{ Form::label('title', 'Title:') }}
4        {{ Form::text('title') }}
5    </div>
6 
7    <div>
8        {{ Form::label('description', 'Description:') }}
9        {{ Form::textarea('description') }}
10    </div>
11{{ Form::close() }}
12//@sujay
Liya
01 Jun 2019
1//$user = User::find($id);
2//if (!$user) { abort (404); }
3//=> do this
4$user = User::findOrFail($id);
5//@sujay