Skip to main content

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

Read more here

Senither/ShareX-Media-Server

43 stars
3 code files
View Senither/ShareX-Media-Server on GitHub

app/Scopes/UserScope.php

Open in GitHub
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Scope;
 
class UserScope implements Scope
{
public function apply(Builder $builder, Model $model)
{
if (auth()->check()) {
$builder->where(
'user_id',
session()->has('imposter_id')
? session()->get('imposter_id')
: request()->user()->id
);
}
}
}

app/Traits/BelongsToUser.php

Open in GitHub
use App\Scopes\UserScope;
 
trait BelongsToUser
{
public static function bootBelongsToUser()
{
static::addGlobalScope(new UserScope());
}
}

app/Models/Url.php

Open in GitHub
use App\Traits\BelongsToUser;
use Illuminate\Database\Eloquent\Model;
 
class Url extends Model
{
use BelongsToUser;
//
}

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.