Week Day Model

For understanding, how the model code works, please refer to country model or company model

Below code create week day model & migration files.

php artisan make:model WeekDay -m
Model class

Replace model class with below code.

There are two fields/properties (dayValue, dayName), which need to add to Model and Migration. dayValue is integer weekday (e.g. 1, 2, 3) and dayName (Monday, Tuesday).

Note: Please use the copy button to copy the source code.

class WeekDay extends Model { use HasFactory; protected $fillable = [ 'dayValue', 'dayName', ]; }
Migration class

Replace the up() and down() methods with the code below.

public function up() { Schema::create('week_days', function (Blueprint $table) { $table->id(); $table->integer('dayValue'); $table->string('dayName'); $table->timestamps(); }); } public function down() { Schema::dropIfExists('week_days'); }

To create/update the table to database, we need to run artisan migrate command

php artisan migrate