Te explico cómo crear un CRUD completo en Laravel tanto para web como para API al mismo tiempo. 1. Configuración Inicial Primero, crea el modelo con migración y controlador: bash php artisan make:model Product -mcr 2. Migración database/migrations/xxxx_create_products_table.php : php <?php use Illuminate \ Database \ Migrations \ Migration ; use Illuminate \ Database \ Schema \ Blueprint ; use Illuminate \ Support \ Facades \ Schema ; return new class extends Migration { public function up ( ) : void { Schema :: create ( 'products' , function ( Blueprint $table ) { $table -> id ( ) ; $table -> string ( 'name' ) ; $table -> text ( 'description' ) -> nullable ( ) ; $table -> decimal ( 'price' , 10 , 2 ) ; $table -> integer ( 'stock' ) ; $table -> timestamps ( ) ; } ) ; } public functi...
Comentarios
Publicar un comentario