You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
837 B
46 lines
837 B
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Common\ProductStatus;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class AgentProduct extends BaseModel
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
|
|
protected $guarded = ['id'];
|
|
|
|
public function product()
|
|
{
|
|
return $this->belongsTo(Product::class)->where('status', ProductStatus::ON_SALE);
|
|
}
|
|
|
|
public function coupon()
|
|
{
|
|
return $this->hasMany(Coupon::class);
|
|
}
|
|
|
|
public function fav()
|
|
{
|
|
return $this->hasOne(UserFav::class);
|
|
}
|
|
|
|
public function agent()
|
|
{
|
|
return $this->belongsTo(Agent::class);
|
|
}
|
|
|
|
public function category()
|
|
{
|
|
return $this->belongsTo(Category::class);
|
|
}
|
|
|
|
public function setChannelIdAttribute($value)
|
|
{
|
|
if (is_array($value)) {
|
|
$this->attributes['channel_id'] = join(',', array_filter($value));
|
|
}
|
|
}
|
|
}
|