php - Testing a pre-loaded Laravel Eloquent model with a query scope -


i've started using laravel's query scopes 1 thing feel i'm missing ability test existing eloquent object defined scope.

say i've set 'published' scope post model

public function scopepublished($q){      return $q->wherenotnull('published_at'); } 

if have queried list of posts , want put symbol beside published ones, ideally want write like

if($post->ispublished()){ /* insert symbol */ } 

...using 'published' scope test each post, there way can (without running additional query each post)?


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -