laravel tips and tricks code example
Example 1: laravel tricks and tips
Route::get('logout', function()
{
Auth::logout();
return Redirect::home();
});
Example 2: laravel tips
$q->where(function ($query) {
$query->where('gender', 'Male')
->where('age', '>=', 18);
})->orWhere(function($query) {
$query->where('gender', 'Female')
->where('age', '>=', 65);
})
Example 3: laravel tricks and tips
Route::get('orders', function()
{
return View::make('orders.index')
->with('orders', Order::all());
});
Example 4: laravel tricks and tips
Article::find($article_id)->increment('read_count');
Article::find($article_id)->increment('read_count', 10);
Product::find($produce_id)->decrement('stock');
Example 5: laravel tricks and tips
$user = [
'email' => 'email',
'password' => 'password'
];
if (Auth::attempt($user))
{
}
Example 6: 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() }}