50 lines
1.2 KiB
PHP
Executable File
50 lines
1.2 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class AuthorizedUser extends Model
|
|
{
|
|
use HasFactory;
|
|
protected $table = 'authorized_users'; // Table name
|
|
protected $primaryKey = 'id';
|
|
public $incrementing = true;
|
|
protected $fillable = [
|
|
'user_id',
|
|
'authorized_user_id',
|
|
'firstname',
|
|
'lastname',
|
|
'phone_number',
|
|
'gender',
|
|
'email',
|
|
'relation_to_user',
|
|
'token',
|
|
'status',
|
|
'created_at',
|
|
'updated_at',
|
|
];
|
|
|
|
// Laravel manages created_at + updated_at automatically
|
|
public $timestamps = true;
|
|
|
|
protected $casts = [
|
|
'user_id' => 'integer',
|
|
'authorized_user_id' => 'integer',
|
|
'email' => 'string',
|
|
'firstname' => 'string',
|
|
'lastname' => 'string',
|
|
'phone_number' => 'string',
|
|
'relation_to_user' => 'string',
|
|
'token' => 'string',
|
|
'status' => 'string',
|
|
];
|
|
|
|
// Relationship: Each authorized user belongs to a user
|
|
public function user()
|
|
{
|
|
return $this->belongsTo(User::class, 'user_id');
|
|
}
|
|
}
|