Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

LaravelDaily/Laravel-Support-Ticketing

294 stars
2 code files
View LaravelDaily/Laravel-Support-Ticketing on GitHub

app/Scopes/AgentScope.php

Open in GitHub
use Illuminate\Database\Eloquent\Scope;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
 
class AgentScope implements Scope
{
public function apply(Builder $builder, Model $model)
{
$user = auth()->user();
if(auth()->check() && request()->is('admin/*') && $user->roles->contains(2))
{
$builder->where('assigned_to_user_id', $user->id);
}
}
}

app/Ticket.php

Open in GitHub
use Illuminate\Database\Eloquent\Model;
use Spatie\MediaLibrary\HasMedia;
 
class Ticket extends Model implements HasMedia
{
//
public static function boot()
{
parent::boot();
//
static::addGlobalScope(new AgentScope);
}
//
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.