Created
March 20, 2019 07:32
-
-
Save dura0ok/cc92ad4f7e23ff17ff824576f7d64b9d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Illuminate\Database\Eloquent\Model; | |
use Illuminate\Http\Request; | |
class Shoplocation extends Model | |
{ | |
protected $guarded = []; | |
protected $hidden = ['created_at', 'updated_at', 'shop_id']; | |
public function shop() | |
{ | |
return $this->hasManyThrough(Shop::class, Category::class, 'shop_id', 'category_id', 'id', 'id '); | |
} | |
public function scopeByCity($query) | |
{ | |
return $query->whereHas('shop', function ($query) { | |
return $query->where('city_id', request()->hasCookie('loc') ? request()->cookie('loc') : 1); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment