<?php
/*
    * Created by VahabDev in Aparat Live
    * Website: https://pourfi.ir
    * Aparat Live: https://www.aparat.com/vahabdev/live
    * Aparat Channel: https://www.aparat.com/vahabdev
    * Rubika Channel: https://rubika.ir/vahabdev
    * Donate: https://reymit.ir/vahabdev
    * Telegram: https://t.me/vahabdev
*/


namespace App\Models;

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

class Client extends Model
{
    use HasFactory;

    protected $fillable = [
        'firstname',
        'lastname',
        'phone',
        'password',
        'state',
        'city',
        'ip',
        'status'
    ];


    public function orders() : HasMany{
        return $this->hasMany(Order::class, 'user_id', 'id');
    }

    public function tickets() : HasMany{
        return $this->hasMany(Ticket::class, 'user_id', 'id');
    }

    public function getStatusLabelAttribute(): string
    {
        return match($this->attributes['status']) {
            'active' => 'فعال',
            'inactive' => 'غیرفعال',
            'banned' => 'مسدود',
            'pending' => 'در انتظار تایید',
            'unverified' => 'تایید نشده',
            default => 'فعال',
        };
    }

}
