public static function bootDraftable()
    {
        if(isset(static::$publishDateField)) static::setPublishDateField(static::$publishDateField);
        
        static::addGlobalScope('published', function (Builder $builder) {
            if (static::isDraftsEnabled()) {
                $builder->where('status', '=', Constants::STATUS_LIVE);

                if (static::publishDateFieldEnabled()) {
                    $builder->where(function ($subQuery) {
                        $subQuery->whereNull(static::$_publishDateField)->orWhere(static::$_publishDateField, '<', static::getConvertedNow());
                    });
                }
            }

            return $builder;
        });
    }
public static function bootDraftable()
    {
        if(isset(static::$publishDateField)) static::setPublishDateField(static::$publishDateField);
        
        static::addGlobalScope('published', function (Builder $builder) {
            if (static::isDraftsEnabled()) {
                $builder->where('status', '=', Constants::STATUS_LIVE);

                if (static::publishDateFieldEnabled()) {
                    $builder->where(function ($subQuery) {
                        $subQuery->whereNull(static::$_publishDateField)->orWhere(static::$_publishDateField, '<', static::getConvertedNow());
                    });
                }
            }

            return $builder;
        });
    }
public static function bootDraftable ( ) { if ( isset ( static :: $ publishDateField ) ) static :: setPublishDateField ( static :: $ publishDateField ) ; static :: addGlobalScope ( 'published' , function ( Builder $ builder ) { if ( static :: isDraftsEnabled ( ) ) { $ builder -> where ( 'status' , '=' , Constants :: STATUS_LIVE ) ; if ( static :: publishDateFieldEnabled ( ) ) { $ builder -> where ( function ( $ subQuery ) { $ subQuery -> whereNull ( static :: $ _publishDateField ) -> orWhere ( static :: $ _publishDateField , '<' , static :: getConvertedNow ( ) ) ; } ) ; } } return $ builder ; } ) ; }
Automatically filters model to only show live items.
Automatically filters model to only show live items .