Answers for "laravel tricks and tips"

PHP
0

laravel tricks and tips

Route::get('orders', function()
{
    return View::make('orders.index')
        ->with('orders', Order::all());
});
//@sujay
Posted by: Guest on September-30-2020
0

laravel tricks and tips

Route::get('logout', function()
{
    Auth::logout();
     
    return Redirect::home();
});
//@sujay
Posted by: Guest on September-30-2020
0

laravel tricks and tips

$user = [
    'email' => 'email',
    'password' => 'password'
];
 
if (Auth::attempt($user))
{
    // user is now logged in!
    // Access user object with Auth::user()
}
//@sujay
Posted by: Guest on September-30-2020
0

laravel tricks and tips

Article::find($article_id)->increment('read_count');
Article::find($article_id)->increment('read_count', 10); // +10
Product::find($produce_id)->decrement('stock'); // -1
//@sujay
Posted by: Guest on September-30-2020
0

laravel tricks and tips

{{ Form::model($order) }}
    <div>
        {{ Form::label('title', 'Title:') }}
        {{ Form::text('title') }}
    </div>
 
    <div>
        {{ Form::label('description', 'Description:') }}
        {{ Form::textarea('description') }}
    </div>
{{ Form::close() }}
//@sujay
Posted by: Guest on September-30-2020
0

laravel tricks and tips

//$user = User::find($id);
//if (!$user) { abort (404); }
//=> do this
$user = User::findOrFail($id);
//@sujay
Posted by: Guest on September-30-2020

Browse Popular Code Answers by Language