Working Day Model
For understanding, how the model code works, please refer to country model or company model
Below code create working day model & migration files.
php artisan make:model WorkingDay -m
Model class
Replace model class with below code.
Note: Please use the copy button to copy the source code.
We need to include the following import statement(s)
use Illuminate\Database\Eloquent\SoftDeletes;
class WorkingDay extends Model
{
use HasFactory;
use SoftDeletes;
protected $fillable = [
'day',
'fullDay',
'company_id'
];
}
Migration class
Replace the up() and down() methods with the code below.
public function up()
{
Schema::create('working_days', function (Blueprint $table) {
$table->id();
$table->integer('day');
$table->boolean('fullDay')->default(0);
$table->foreignId('company_id')->constrained();
$table->softDeletes();
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('working_days');
}
To create/update the table to database, we need to run artisan migrate command
php artisan migrate