Figured out a decent solution. Add to AppServiceProvider@register:
$this->app->bind('TCG\Voyager\Models\Post', function ($app) {
return new App\Post;
});
Create the new model that extends Voyager's model, and use a conditional addGlobalScope:
<?php
namespace App;
use TCG\Voyager\Models\Post as VoyagerPost;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Auth;
class Post extends VoyagerPost
{
/**
* The "booting" method of the model.
*
* @return void
*/
protected static function boot()
{
parent::boot();
// Customize your own rule here!
if (\Request::is('management/*') && Auth::user()->canBlogSolo()) {
static::addGlobalScope('author', function (Builder $builder) {
$builder->where('author_id', '=', Auth::user()->id);
});
}
}
}
http://eloquentbyexample.com/course/lesson/lesson-4-scopes