<?php
namespace App\model;
use Illuminate\Database\Eloquent\Model;
class Shop extends Model
{ // protected $visible = ['name', 'Phone'];
//
protected $hidden = ['city','Cities','Dealers','dealer_id'];
protected $appends = ['ShopCity','Dealer','ProductCount','ShopsComments','SalesCount','OrdersCount'];
public function getSalesCountAttribute()
{
$Productcomments = Productcomment::
where('shop_id', $this->id)->
get();
return 5000;
}
public function getOrdersCountAttribute()
{
$Productcomments = Productcomment::
where('shop_id', $this->id)->
get();
return 5;
}
public function getShopsCommentsAttribute()
{
$Productcomments = Productcomment::
where('shop_id', $this->id)->
get();
return $Productcomments;
}
public function Cities()
{
return $this->hasOne('App\model\Cities' ,'id', 'city');
// ->select(app('App\model\Cities')->getTable().'.name');
}
public function getShopCityAttribute()
{
return $this->Cities;
}
public function getProductCountAttribute()
{
$Products = Products:: where('shop', $this->id)->get();
return count($Products) ;
}
public function Dealers()
{
return $this->hasOne('App\model\Customer' ,'id', 'dealer_id');
// ->select(app('App\model\Customer')->getTable().'.first_name','.last_name');
}
public function getDealerAttribute()
{
return $this->Dealers;
}
}