<?php

namespace App\Models;

use App\Models\Chat;
use App\Models\User;
use App\Models\Category;
use App\Models\Transaction;
use App\Models\Notification;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Business extends Model
{
    use HasFactory;
    protected $fillable = ['name','slug', 'address', 'phone', 'website', 'user_id', 'admin_id', 'is_feature','cities_id','expire_at'];
    protected $casts = ['is_paid' => 'boolean', 'is_feature' => "boolean"];
     // Define the many-to-many relationship with City
    public function cities()
    {
        return $this->belongsToMany(City::class, 'business_city', 'business_id', 'city_id');
    }
    public function admin()
    {
        return $this->belongsTo(Admin::class, 'admin_id');
    }

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

    public function categories()
    {
        return $this->belongsToMany(Category::class);
    }

    public function chats()
    {
        return $this->hasMany(Chat::class);
    }
   
    public function transactions()
    {
        return $this->hasOne(Transaction::class);
    }
    public function zoomMeeting()
    {
        return $this->hasOne(Business::class);
    }

    public function notifications()
{
    return $this->morphMany(Notification::class, 'notifiable');
}
}