Created
December 10, 2015 03:11
-
-
Save hthuong09/a6e424ca356f44908036 to your computer and use it in GitHub Desktop.
Global scope eloquent
This file contains 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 | |
class Comment extends Eloquent { | |
public function newQuery() | |
{ | |
return parent::newQuery()->where('cat', '=', 6); | |
} | |
// Now when you will perform a query like : | |
// Comment::count() | |
// Your scope defined in the newQuery will be used | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment