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.
53 lines
1.2 KiB
53 lines
1.2 KiB
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Scopes\AdminProjectScope;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class Product extends SoftDeletesModel
|
|
{
|
|
protected $table = "product";
|
|
|
|
protected static function booted()
|
|
{
|
|
static::addGlobalScope(new AdminProjectScope());
|
|
}
|
|
|
|
public function getPosterUrlAttribute()
|
|
{
|
|
$protocol = request()->secure() ? "https" : "http";
|
|
return $this->poster ? $protocol . "://" . request()->getHost() . $this->poster : $this->poster;
|
|
}
|
|
|
|
public function project()
|
|
{
|
|
return $this->belongsTo(Project::class);
|
|
}
|
|
|
|
public function defaultItem()
|
|
{
|
|
return $this->hasOne(ProductItems::class)->where("patient_quantity", 1);
|
|
}
|
|
|
|
public function productItems()
|
|
{
|
|
return $this->hasMany(ProductItems::class);
|
|
}
|
|
|
|
public function productParamedicLevels()
|
|
{
|
|
return $this->hasMany(ProductParamedicLevel::class);
|
|
}
|
|
|
|
public function factors()
|
|
{
|
|
return $this->hasMany(Factor::class);
|
|
}
|
|
|
|
public function lastdayCheckoutRules()
|
|
{
|
|
return $this->hasMany(LastdayChekcoutRule::class, "product_id")->orderBy("before_time");
|
|
}
|
|
}
|