D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
forge
/
re-viewers.com
/
app
/
Models
/
Filename :
Review.php
back
Copy
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; class Review extends Model { protected $table = 'reviews'; protected $fillable = [ 'category_id', 'product_title', 'product_image', 'product_desc', 'product_date', 'total_views', 'total_rate', 'rate_avg', 'featured', 'status', 'subcategory_id', 'subsubcategory_id', 'brand_id' ]; public function category(): BelongsTo { return $this->belongsTo(Category::class); } public function sliders() { return $this->hasMany(Slider::class); } public function comments() { return $this->hasMany(Comment::class, 'product_id'); } public function subcategory() { return $this->belongsTo(Category::class, 'subcategory_id'); } public function subsubcategory() { return $this->belongsTo(Category::class, 'subsubcategory_id'); } public function brand() { return $this->belongsTo(Brand::class); } // داخل class Review extends Model public function scopePresentable($query) { return $query ->where('status', 1) ->whereNotNull('rate_avg')->where('rate_avg', '>', 0) ->whereNotNull('total_views')->where('total_views', '>', 0) ->whereNotNull('product_title')->where('product_title', '!=', '') ->whereNotNull('product_image')->where('product_image', '!=', ''); } }