Skip to content

Instantly share code, notes, and snippets.

@tanftw
Created October 23, 2015 18:12
Show Gist options
  • Select an option

  • Save tanftw/740432160cb9f8c19c34 to your computer and use it in GitHub Desktop.

Select an option

Save tanftw/740432160cb9f8c19c34 to your computer and use it in GitHub Desktop.
CanUseCreator trait for Laravel 5
<?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