Common syntax | Shorter and more readable syntax |
---|---|
Session::get('cart') | session('cart') |
$request->session()->get('cart') | session('cart') |
Session::put('cart', $data) | session(['cart' => $data]) |
$request->input('name'), Request::get('name') | $request->name, request('name') |
return Redirect::back() | return back() |
is_null($obj->relation) ? null : $obj->relation->id | optional($obj->relation)->id |
return view('index')->with('title', $title)->with('client', $client) | return view('index', compact('title', 'client')) |
request->has('value') ? request->value : 'default' | request->get('value', 'default') |
Carbon::now(), Carbon::today() | now(), today() |
App::make('Class') | app('Class') |
->where('column', '=', 1) | ->where('column', 1) |
->orderBy('created_at', 'desc') | ->latest() |
->orderBy('age', 'desc') | ->latest('age') |
->orderBy('created_at', 'asc') | ->oldest() |
->select('id', 'name')->get() | ->get(['id', 'name']) |
->first()->name | ->value('name') |
Last active
June 1, 2021 07:24
-
-
Save yavgel85/ea04de11952827656d8a5558d627244b to your computer and use it in GitHub Desktop.
Shorter and more readable syntax #laravel #bestpractices
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment