<?php

namespace App\Models;

use App\Models\Role;
use App\Models\LinkedSocialAccount;
use App\Models\Suppliers;
use App\Models\Postulations;
use App\Models\Report;
use App\Models\ReportComment;
use App\Models\Property;
use App\Models\ContractComment;
use App\Models\CurrentContracts;
use App\Models\FinishedContracts;
use Laravel\Passport\HasApiTokens;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Notifications\Notifiable;
use App\Notifications\PasswordReset;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use HasApiTokens;
    use Notifiable;
    protected $fillable = [
        'name',
        'email',
        'profile_photo',
        'role_id',
        'social_id',
        'stripe_customer_id',
        'password',
        'phone',
        'phone_verified_at'
    ];
    protected $hidden = [
        'password',
        'remember_token',
    ];

    /**
     * Send the password reset notification.
     *
     * @param  string  $token
     * @return void
     */
    public function sendPasswordResetNotification($token)
    {
        $this->notify(new PasswordReset($token));
    }

    public function linkedSocialAccounts()
    {
        return $this->hasMany(LinkedSocialAccount::class);
    }

    public function suppliers()
    {
        return $this->hasOne(Suppliers::class);
    }

    public function postulations()
    {
        return $this->hasMany(Postulations::class);
    }

    public function currentcontracts()
    {
        return $this->hasMany(CurrentContracts::class);
    }

    public function finishedcontracts()
    {
        return $this->hasMany(FinishedContracts::class);
    }

    public function reports()
    {
        return $this->hasMany(Report::class);
    }

    public function reportcomments()
    {
        return $this->hasMany(ReportComment::class);
    }

    public function properties()
    {
        return $this->hasMany(Property::class);
    }

    public function contractcomments()
    {
        return $this->hasMany(ContractComment::class);
    }

    public function roles()
    {
        return $this->belongsTo(Role::class, 'role_id');
    }
}
