12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- use OwenIt\Auditing\Contracts\Auditable;
- class Recipes extends Model implements Auditable
- {
- use \OwenIt\Auditing\Auditable;
- protected $table = "tb_dm_recipe";
- protected $auditInclude = [
- 'status',
- 'inventory_options',
- 'allow_pre_order',
- 'name',
- 'arabic_name',
- 'price',
- 'deleted_at',
- 'short_description'
- ];
- public function categories(){
- return $this->hasMany('App\Models\MapRecipeCategories','recipe_id','id');
- }
- public function product_faqs(){
- return $this->hasMany('App\Models\ProductFAQs','product_id','id')->whereNull('deleted_at');
- }
- public function variations(){
- return $this->hasMany('App\Models\VariationData','product_id','id')->whereNull('deleted_at');
- }
- public function categories_name(){
- return $this->hasOne('App\Models\MapRecipeCategories','recipe_id','id');
- }
- public function main_images(){
- return $this->hasOne('App\Models\Photos','recipe_id','id')->where('photo_type','main_image');
- }
- public function restuarants(){
- return $this->belongsTo('App\Models\Restaurants','resto_id','id');
- }
- public function galleries(){
- return $this->hasMany('App\Models\Photos','recipe_id','id')->where('photo_type','gallery')->whereNull('deleted_at');
- }
- public function extra_options(){
- return $this->hasMany('App\Models\ExtraOptions','recipe_id','id')->whereNull('deleted_at');
- }
- public function extra_options_with_items(){
- return $this->hasMany('App\Models\ExtraOptions','recipe_id','id')->whereNull('deleted_at');
- }
- public function items_sales(){
- $a = $this->hasMany('App\Models\OrderItems','recipe_id','id')->whereHas('orders',function($q){
- $q->whereIn('status',['On_Road','Has_Delivered']);
- // $q->where('status','!=','Initial');
- });
- return $a;
- }
- /*public function recipe_with_category(){
- return $this->belongsTo('App\MapRecipeCategories','recu','category')->select(DB::raw('sum(tb_dm_order_items.qty*tb_dm_order_items.price) AS total_price'))->where("status",1);
- }*/
- }
|