Manually register a user in Laravel (Tinker)
User::create([
'email' => 'name@example.com',
'name' => 'Alex',
'password' => bcrypt('password')
])
Update a product if the amount is upper to 0
$product->update(['amount' => max(0, request('amount'))]);
Age macro with Carbon
\Illuminate\Support\Carbon::macro('age', function ($date) {
return $this->diff($this->parse($date))->format('%y');
});
// usage:
now()->age('1988-08-25'); // 29
now()->addDays()->ge('1988-08-25'); // 30
Easy way to disable all logs from your app. In "logging.php":
'void' => [
'driver' => 'monolog',
'handler' => \Monolog\Handler\NullHandler::class
],
Pass data up the blade layout you are extending
@extends('layouts.app', ['nologo' => true])