
PK 
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Product extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'products';
use SoftDeletes;
/**
* The products that should be mutated to dates.
*
* @var array
*/
protected $dates = ['deleted_at'];
/**
* The products that are mass assignable.
*
* @var array
*/
protected $fillable = [
'product_name','product_slug','product_desc','product_sortby','isactive','isdelete','addedby','created_at','updated_at','deleted_at','visitor'
];
/**
* tree view a query show tree.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public static function attrHierarchicalTree()
{
$products = product::select('id','category_id','category_ids','attribute_id','product_name','product_slug')->orderBy('product_sortby','asc')->get()->toArray();
return $products = buildAttrTree($products);
}
/**
* Scope a query to only include active users.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeActive($query)
{
return $query->where('isactive', 1);
}
/**
* Get the index name for the model.
*
* @return string
*/
public function category()
{
return $this->belongsTo('App\Category');
}
}


PK 99