<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Rider extends Model
{
    use HasFactory;

    protected $fillable = [
        'user_id', 'dry_cleaner_id', 'id_number', 'profile_pic',
        'motorbike_plates', 'license_number', 'status',
        'current_lat', 'current_lng',
    ];

    protected $casts = [
        'current_lat' => 'decimal:7',
        'current_lng' => 'decimal:7',
    ];

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function dryCleaner()
    {
        return $this->belongsTo(DryCleaner::class);
    }

    public function pickupOrders()
    {
        return $this->hasMany(Order::class, 'pickup_rider_id');
    }

    public function deliveryOrders()
    {
        return $this->hasMany(Order::class, 'delivery_rider_id');
    }
}
