HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-26-0-120 6.17.0-1009-aws #9~24.04.2-Ubuntu SMP Fri Mar 6 23:50:29 UTC 2026 x86_64
User: ubuntu (1000)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/www/html/dashboard.orbiwheels.com/app/Models/Driver.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Laravel\Sanctum\HasApiTokens;

class Driver extends Model
{
    use SoftDeletes,HasApiTokens;
    protected $fillable = [
        'transporter_id',
        'name',
        'email',
        'age',
        'gender',
        'phone',
        'alternate_number',
        'otp',
        'otp_expires_at',
        'license_number',
        'aadhaar_number',
        'experience',
        'mode',
        'is_verified',
        'about',
        'image',
        'status',
    ];

    public function documents()
    {
        return $this->morphMany(Document::class, 'owner');
    }
    public function transporter()
    {
        return $this->belongsTo(Transporter::class, 'transporter_id');
    }

    public function refreshVerificationStatus()
    {
        $this->load('documents'); 
        $hasDocs = $this->documents()->count() > 0;
        $allDocsVerified = $hasDocs && $this->documents()->where('is_verified', 0)->count() == 0;

        $this->is_verified = $allDocsVerified;
        $this->save();
    }
}