<?php

namespace App\Models;

// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Storage;
use Laravel\Sanctum\HasApiTokens;

class Frontuser extends Authenticatable
{
    use HasApiTokens, HasFactory, Notifiable;
    public $guard = 'front';

    /**
     * The attributes that are mass assignable.
     *
     * @var array<int, string>
     */
    // protected $fillable = [
    //     'name',
    //     'email',
    //     'password',
    // ];

    protected $guarded = [];

    /**
     * The attributes that should be hidden for serialization.
     *
     * @var array<int, string>
     */
    protected $hidden = [
        'password',
        'remember_token',
    ];

    /**
     * The attributes that should be cast.
     *
     * @var array<string, string>
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];

    // public function setAminityIdAttribute($value){
    //     if($this->attributes['aminity_id'] !=NULL){
    //         $this->attributes['aminity_id'] = json_encode($this->attributes['aminity_id']);
    //     }
    // }


    public function category()
    {
        return $this->belongsTo(Category::class);
    }

    public function galleries()
    {
        return $this->hasMany(Upload::class,'related_id');
    }

    public function videos()
    {
        return $this->hasMany(UploadVideo::class,'related_id');
    }


    public function country()
    {
        return $this->belongsTo(Country::class);
    }


    public function state()
    {
        return $this->belongsTo(State::class);
    }


    public function city()
    {
        return $this->belongsTo(City::class);
    }

    public function portfolio()
    {
        return $this->hasMany(Portfolio::class,'company_id');
    }


    // public function getImageUrlAttribute()
    // {
    //     return Storage::disk('imagesfp')->url($this->image);
    // }



}
