<?php

namespace App\Models;

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

class Office extends Model
{
    use HasFactory, Notifiable;

    protected $fillable = [
        'name', 'address', 'phone', 'employers_number','email', 'image', 'booking_commission', 'exchange_commission', 'canellation_commission','is_admin'
    ];

    function getPublicImageAttribute(){
        return $this->image? 'uploads/'.$this->image: null;
    }

    public function admin()
    {
        return $this->hasOne(User::class);
    }

    public function account()
    {
        return $this->hasOne(Account::class);
    }

    public function receivesBroadcastNotificationsOn()
    {
        return 'offices.'.$this->id;
    }
}
