- Controller
- Route
- View
- Eloquent
- Paginate
- Create
- Update
- Delete
- Policy
- Seeder
- Artisan
- Package
- Spatie - Laravel Permission
- Laravel Pint - Laravel Pint is an opinionated PHP code style fixer for minimalists.
- Larastan - Adds code analysis to Laravel improving developer productivity and code quality.
Create a single method controller:
php artisan make:controller WelcomeController --invokable
Create resource controller with binding model:
php artisan make:controller UserController --model=User
Create route using closure:
Route::get('/', function() {
return view('welcome');
});
Create route using view only:
Route::view('/', 'welcome');
Create route using single method / invokable controller:
use App\Http\Controllers\WelcomeController;
Route::get('/', WelcomeController::class);
Create resource controller routes:
use App\Http\Controllers\UserController;
Route::resource('users', UserController::class);
Looping:
@foreach($users as $user)
...
@endforeach
Control Structure:
@if(...)
...
@endif
@can('delete', $user)
...
@endcan
Get all data:
$users = User::all();
// OR
$users = User::get();
Paginate data:
$users = User::paginate();
Create new record:
$user = User::create([
'name' => 'Nasrul',
'email' => '[email protected]',
]);
Update record:
User::where('email', '[email protected]')
->update([
'name' => 'Nasrul Hazim',
]);
// OR
$user->update([
'name' => 'Nasrul Hazim',
]);
Delete record:
User::where('email', '[email protected]')->delete();
// OR
$user->delete();
List of available commands:
php artisan
Create new seeder:
php artisan make:seeder PermissionSeeder
Create new controllers:
php artisan make:controller UserController --model=User
Create new policy:
php artisan make:policy UserPolicy --model=User
Create new seeder:
php artisan make:seeder PermissionSeeder
Seed data:
php artisan db:seed
Seed specific seeder:
php artisan db:seed --class=PermissionSeeder