Created
October 23, 2015 18:12
-
-
Save tanftw/740432160cb9f8c19c34 to your computer and use it in GitHub Desktop.
CanUseCreator trait for Laravel 5
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; | |
| trait CanUseCreator | |
| { | |
| public function scopeOfCreator($query, $value) | |
| { | |
| return $query->whereCreatorId($value); | |
| } | |
| public function creator() | |
| { | |
| return $this->belongsTo('App\User', 'creator_id', 'id'); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment