Leave Type Approving Officer Model
For understanding, how the model code works, please refer to country model or company model
Below code create leave type apporoving officer model & migration files.
php artisan make:model LeaveTypeApprovingOfficer -m
Model class
There are two fields/properties (user_id, leave_type_id). user_id
is the approving user id and leave_type_id
is the id of leave type.
Replace model class with below code.
Note: Please use the copy button to copy the source code.
class LeaveTypeApprovingOfficer extends Model
{
use HasFactory;
protected $fillable = [
'user_id',
'leave_type_id',
];
}
Migration class
Replace the up() and down() methods with the code below.
public function up()
{
Schema::create('leave_type_approving_officers', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained();
$table->foreignId('leave_type_id')->constrained();
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('leave_type_approving_officers');
}
To create/update the table to database, we need to run artisan migrate command
php artisan migrate