User Approving Officer Model
For understanding, how the model code works, please refer to country model or company model
Below code create user approving officer model & migration files.
php artisan make:model UserApprovingOfficer -m
Model class
user_id
and approving_id
need to add to Model and Migration. user_id
is user id and approving_id
is approving officer user id.
Replace model class with below code.
Note: Please use the copy button to copy the source code.
class UserApprovingOfficer extends Model
{
use HasFactory;
protected $fillable = [
'user_id',
'approving_id',
];
}
Migration class
public function up()
{
Schema::create('user_approving_officers', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained();
$table->foreignId('approving_id')->constrained('users');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('user_approving_officers');
}
To create/update the table to database, we need to run artisan migrate command
php artisan migrate