69 lines
2.0 KiB
PHP
69 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* نموذج الراكب (Passenger Model)
|
|
*
|
|
* الغرض من الملف:
|
|
* إدارة بيانات الركاب المستخدمين للتطبيق.
|
|
*
|
|
* كيفية العمل:
|
|
* 1. يرتبط بجدول (passengers) في قاعدة البيانات الأساسية.
|
|
* 2. يستخدم معرّفاً نصياً (String ID) كمفتاح أساسي بدلاً من الأرقام المتسلسلة.
|
|
* 3. يحتوي على قائمة بالحقول المشفرة لضمان خصوصية بيانات الركاب.
|
|
* 4. يدير علاقات الراكب مع: المحفظة المباشرة، الرحلات، والتقييمات.
|
|
*/
|
|
class Passenger extends Model
|
|
{
|
|
protected $connection = 'primary';
|
|
protected $table = 'passengers';
|
|
protected $primaryKey = 'id';
|
|
protected $keyType = 'string';
|
|
public $incrementing = false;
|
|
public $timestamps = true;
|
|
|
|
const CREATED_AT = 'created_at';
|
|
const UPDATED_AT = 'updated_at';
|
|
|
|
protected $fillable = [
|
|
'id', 'phone', 'email', 'password', 'gender', 'status',
|
|
'birthdate', 'site', 'first_name', 'last_name', 'sosPhone',
|
|
'education', 'employmentType', 'maritalStatus',
|
|
'api_key', 'api_secret',
|
|
];
|
|
|
|
protected $hidden = ['password', 'api_secret'];
|
|
|
|
public const ENCRYPTED_FIELDS = [
|
|
'first_name', 'last_name', 'phone', 'gender', 'email', 'birthdate',
|
|
];
|
|
|
|
public function token()
|
|
{
|
|
return $this->hasOne(PassengerToken::class, 'passengerID', 'id');
|
|
}
|
|
|
|
public function wallet()
|
|
{
|
|
return $this->hasMany(PassengerWallet::class, 'passenger_id', 'id');
|
|
}
|
|
|
|
public function rides()
|
|
{
|
|
return $this->hasMany(Ride::class, 'passenger_id', 'id');
|
|
}
|
|
|
|
public function ratings()
|
|
{
|
|
return $this->hasMany(RatingPassenger::class, 'passenger_id', 'id');
|
|
}
|
|
|
|
public function scopeActive($query)
|
|
{
|
|
return $query->where('status', 'notDeleted');
|
|
}
|
|
}
|