src/Scopes/PostPublishedScope.php
/**
     * For normal users, add a global scope for BlogEtcPosts to never return unpublished posts.
     *
     * @param Builder $builder
     * @param Model   $model
     *
     * @return void
     */
For normal users, add a global scope for BlogEtcPosts to never return unpublished posts.
@param Builder $builder
@param Model   $model

@return void
For normal users add a global scope for BlogEtcPosts to never return unpublished posts . @param Builder $builder @param Model $model @return void
public function apply(Builder $builder, Model $model): void
    {
        if (Gate::denies('blog-etc-admin')) {
            $builder->where('is_published', true);
            $builder->where('posted_at', '<=', Carbon::now());
        }
    }
public function apply ( Builder $ builder , Model $ model ) : void { if ( Gate :: denies ( 'blog-etc-admin' ) ) { $ builder -> where ( 'is_published' , true ) ; $ builder -> where ( 'posted_at' , '<=' , Carbon :: now ( ) ) ; } }
For normal users, add a global scope for BlogEtcPosts to never return unpublished posts.
For normal users add a global scope for BlogEtcPosts to never return unpublished posts .
// user is a guest, or if logged in they can't manage blog posts