<?php

namespace App\Models;

use App\Http\Controllers\Api\Admin\UserController;
use Illuminate\Database\Eloquent\Model;

/**
 * @mixin IdeHelperSavedListings
 */
class SavedListings extends Model
{
    protected $fillable = [
        'listing_id',
        'user_id'

    ];

    protected $casts = [
        'listing_id' => 'integer',
        'user_id' => 'integer'
    ];

    public function users()
    {
        return $this->belongsToMany(User::class,'saved_listings');
    }

    public function listings()
    {
        return $this->belongsToMany(Listing::class,'saved_listings')->where('status','published');
    }
}
