Artisan
php artisan serv //lance un serveur de test |
php artisan down //Met l'application en maintenance |
php artisan up //enleve l'application de la maintenance |
php artisan env //affiche les variables d'environement |
php artisan help //affiche l'aide de la commande |
php artisan list //list les commandes |
php artisan optimize //optimise l'application |
php artisan clear-compiled //efface du cache les fichiers compilés |
php artisan tinker // lance l'application en mode console |
Make
php artisan make:controller MonController |
php artisan make:command MaCommande |
php artisan make:event Monevenement |
php artisan make:job MonJob |
php artisan make:listener MonListener |
php artisan make:middleware MonMiddleWare |
php artisan make:migration MaMigration |
php artisan make:model MonModel |
php artisan make:provider MonProvider |
php artisan make:request MaRequest |
php artisan make:seeder MonSeeder |
Blade Layout
@if(condition)
@else
@endif
@foreach($foo as $bar)
@endforeach
@include('folder.page')
@yield('section')
@extends('template')
@section('section')
@endsection
|
Eloquent
class Post extend Model{
protected $primaryKey = "IDPost"
protected $table = "post"
}
Post::find(1);
Post::where('titre', '=', 'valeur')->get();
Post::join('table', 'post.idTable', 'table.IDTable')->get();
$post = new Post();
$post->titre = "hello";
$post->save();
$post = Post::find(1);
$post->titre = "modif"
$post->save();
$post->delete();
|
|
|
Route
php artisan route:cache //Met les routes en cache |
php artisan route:clear //Supprime le cache des routes |
php artisan route:list //affiche la liste des routes |
Route
Route::get('/',function (){
return view('hello');
});
Route::get('/post/{id}', function($id){
return view('post', ["id"=>$id]);
});
Route::get('/add', 'MusiqueController@formAdd');
Route::get('/add', 'MusiqueController@formAdd')->name('showAddForm');
Route::get('/post/{id}', "MusiqueController@detail")->where('id', '[0-9]+');
Route::get('/', "controller@example");
Route::post('/', "controller@example");
Route::put('/', "controller@example");
Route::patch('/', "controller@example");
Route::delete('/', "controller@example");
Route::prefix('api', function (){
Route::get('/', function (){
return view('api');
});
Route::get('/test', function (){
return view('api');
});
});
Route::middleware(['first', 'second'])->group(function () {
Route::get('/', function () {
});
Route::get('user/profile', function () {
});
});
|
Seeder
php artisan migrate --seed |
Seeder
class DatabaseSeeder extends Seeder
{
public function run()
{
}
}
|
Migration
php artisan migrate |
php artisan migrate:install |
php artisan migrate:rollback |
php artisan migrate:refresh |
php artisan migrate:reset |
php artisan migrate:status |
Migration
class CreateMusiquesTable extends Migration
{
public function up()
{
Schema::create('musiques', function (Blueprint $table) {
$table->increments('id');
$table->integer('ordre');
$table->string('titre',64);
$table->string('description',256)->nullable();
$table->string('url',256);
$table->date('publication');
$table->integer('categorie_id')->unsigned();
$table->foreign('categorie_id')->references('id')->on('categories');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('musiques');
}
}
|
|