Php artisan make controller e modello

Esempi di codice

4
0

crea modello con il controller laravel

php artisan make:controller CustomersController --model=Customer
3
0

esegui il comando artisan dal controller

If you have simple job to do you can do it from route file. 
For example you want to clear cache. In terminal it would be php artisan 
cache:clear In route file that would be:

\Artisan::call('cache:clear');
2
0

crea modello con il controller laravel

php artisan make:model Customer
php artisan make:controller CustomersController --resource
1
0

crea modello, controller e migrazione in un singolo comando laravel

php artisan make:model Products -mcr

  -m, --migration Create a new migration file for the model.
  -c, --controller Create a new controller for the model.
  -r, --resource Indicates if the generated controller should be a resource controller
   
newer versions of laravel > 5.6
    
    php artisan make:model Products -a
      
    -a, --all Generate a migration, factory, and resource controller for the model
0
0

usa il comando php artisan attraverso il controller

<?php
Route::get('/foo', function () {
    Artisan::queue('email:send', [
        'user' => 1, '--queue' => 'default'
    ]);
    //
});
0
0

crea il controller del modello in un singolo comando

# to make only Model Class
php artisan make:model Customer

# to make resource controller
php artisan make:controller CustomersController --resource

# make controller for already existing Model Class (binded to model)
php artisan make:controller CustomersController --model=Customer

# to make  model, migration and controller all in one command
php artisan make:model User -mcr
# here m for migration, c for controller, r for resource methods in controller

In altre lingue

Questa pagina è in altre lingue

Русский
..................................................................................................................
English
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................