<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;

class Auction extends Model
{
    //
    protected $fillable = [
        'amount','product_id','user_id'
        ];
    /**
     * Get the description of the Ad.
     * @return HasMany
     */
    public function descriptions($language_id= 0) :HasMany
    {
        if ($language_id) {
            return $this->hasMany(AdDescription::class)->where('language_id', $language_id);
        }
        return $this->hasMany(AdDescription::class);
    }
    public function photos() :HasMany
    {
        
        return $this->hasMany(AuctionPhoto::class);
    }
    public function user() 
    {
        
        return $this->belongsTo(User::class,'user_id');
    }
}
