Complete the code to define a Laravel migration for a table named correctly.
Schema::create('[1]', function (Blueprint $table) { $table->id(); $table->timestamps(); });
Laravel expects table names to be plural and lowercase, like users.
Complete the code to specify the table name in a Laravel model.
class User extends Model { protected $table = '[1]'; }
The model should specify the plural lowercase table name, users.
Fix the error in the migration table name to follow Laravel conventions.
Schema::create('[1]', function (Blueprint $table) { $table->id(); $table->timestamps(); });
Table names must be plural and lowercase, so users is correct.
Fill both blanks to create a migration for a pivot table between users and roles.
Schema::create('[1]', function (Blueprint $table) { $table->foreignId('[2]_id')->constrained()->onDelete('cascade'); $table->foreignId('role_id')->constrained()->onDelete('cascade'); $table->primary(['[2]_id', 'role_id']); });
The pivot table name is the two related table names in alphabetical order, role_user. The foreign key uses the singular form user.
Fill all three blanks to define a Laravel model with a custom table name and primary key.
class Product extends Model { protected $table = '[1]'; protected $primaryKey = '[2]'; public $incrementing = [3]; }
The model uses a custom table name products_custom, a custom primary key product_id, and sets incrementing to false if the key is not auto-incrementing.