- Create a new Laravel project via the Composer create-project command ☟
composer create-project laravel/laravel:^9.0 projectname
- Create a new Laravel project via the Composer create-project command inside a folder ☟
composer create-project laravel/laravel:^9.0 .
You can install any version of laravel project by replacing the version only.
composer create-project laravel/laravel:^version projectname
- Make a controller via artisan command ☟
php artisan make:controller IamController
Note: When registering routes for controllers, it accepts the uri name, name of the controller with method name.
Route::get('/iam/{id}', [IamController::class, 'show']);
- Make a single action controller via artisan command ☟
php artisan make:controller IamController --invokable
Note: When registering routes for single action controllers, it accepts two parameters (url & the name of the controller) only.
Route::get('/uri_iam', IamController::class);
- Make resource controller via artisan command ☟
php artisan make:controller IamController --resource
Note: When registering routes for resource controllers, it accepts two parameters (url & the name of the controller) only.
Route::get('/uri_iam', IamController::class);
-
Make resource controller specifying the Model instance via artisan command ☟
php artisan make:controller IamController --model=ModelName --resource
-
Make resource controller specifying the Model instance from a Request via artisan command ☟
php artisan make:controller IamController --model=ModelName --resource --requests
-
Make an API resource controller via artisan command ☟
php artisan make:controller IamController --api
-
Create an Eloquent Model via artisan command ☟
php artisan make:model ModelName
-
Create an Eloquent Model generating migration via artisan command ☟
php artisan make:model ModelName --m Or php artisan make:model ModelName --migration
-
Generate various other types of classes while generating a model, such as factories, seeders, policies, controllers, and form requests. ☟
# Generate a model and a ModelFactory class... php artisan make:model ModelName --factory php artisan make:model ModelName -f # Generate a model and a ModelSeeder class... php artisan make:model ModelName --seed php artisan make:model ModelName -s # Generate a model and a ModelController class... php artisan make:model ModelName --controller php artisan make:model ModelName -c # Generate a model, ModelController resource class, and form request classes... php artisan make:model ModelName --controller --resource --requests php artisan make:model ModelName -crR # Generate a model and a ModelPolicy class... php artisan make:model ModelName --policy # Generate a model and a migration, factory, seeder, and controller... php artisan make:model ModelName -mfsc # Shortcut to generate a model, migration, factory, seeder, policy, controller, and form requests... php artisan make:model ModelName --all # Generate a pivot model... php artisan make:model Member --pivot
-
Inspecting Model provides a convenient overview of all the model's attributes and relations ☟
php artisan model:show ModelName
- Migrate All The Tables ☟
php artisan migrate
- Migrate All The Tables & Remove All Data ☟
php artisan migrate:refresh
- Migrate All The Tables & Remove All Data & Run Seeder ☟
php artisan migrate:refresh --seed
- Migrate A Specific Table & Remove Data From That Table Only ☟
php artisan migrate:refresh --path=database/migrations/2023_10_03_009502_create_users_table.php
- Migrate A Specific Table to add/update/delete a column ☟
php artisan migrate --path=database/migrations/2023_10_03_009502_add_phone_to_users_table.php
- Create A Seeder
php artisan make:seeder IamSeeder
- Run Seeder(s)
php artisan db:seed
- Run A Specific Seeder
php artisan db:seed --class=SeederFileName
- Image Dimension Validation Rules
# required image 'icon' => 'required|image' # required image with file extentions 'icon' => 'required|image|mimes:png,webp,svg' # required image with fixed size dimension pixels 'icon' => 'required|image|mimes:png,webp,svg|dimensions:width=512,height=512' # required image with fixed size dimension ratio 'icon' => 'required|image|mimes:png,webp,svg|dimensions:ratio=2/1' # required image with maximum size of dimension pixels 'icon' => 'required|image|mimes:png,webp,svg|dimensions:max_width=512,max_width=512' # required image with minimum size of dimension pixels 'icon' => 'required|image|mimes:png,webp,svg|dimensions:min_width=512,min_width=512'