Welcome Guest, Not a member yet? Register   Sign In
beforeFind functions not working when paginating
#1

Blog page pagination query;

PHP Code:
$blogQuery model('Blogs');
$list $blogQuery->where('locale'$this->request->getLocale())->where('published_at IS NOT NULL',null,false)->orderBy('tarih','DESC')->paginate(16);
$pager $blogQuery->pager


If I don't add where values before the paging function, it doesn't run the beforeFind functions in the model.

Blog Model;
PHP Code:
class Blogs extends Model
{
    protected $DBGroup          'default';
    protected $table            'blogs';
    protected $primaryKey      'id';
    protected $useAutoIncrement true;
    protected $insertID        0;
    protected $returnType      = \App\Entities\Blogs::class;
    protected $useSoftDeletes  true;
    protected $protectFields    true;
    protected $allowedFields    = [];

    // Dates
    protected $useTimestamps true;
    protected $dateFormat    'datetime';
    protected $createdField  'created_at';
    protected $updatedField  'updated_at';
    protected $deletedField  'deleted_at';

    // Validation
    protected $validationRules      = [];
    protected $validationMessages  = [];
    protected $skipValidation      false;
    protected $cleanValidationRules true;

    // Callbacks
    protected $allowCallbacks true;
    protected $beforeFind    = ['Published','Locale'];


    public function Published($data){
        $this->where('published_at IS NOT NULL',null,false);
        return $data;
    }

    public function Locale($data){
        $request service('request');
        $this->where('locale',$request->getLocale());
        return $data;
    }

Reply




Theme © iAndrew 2016 - Forum software by © MyBB