The bizarre problem of laravel orm where condition failure.

abstract class BaseRepositoryApi extends \Prettus\Repository\Eloquent\BaseRepository
{
    public function paginate($perPage = null, $page = null, $columns = ["*"])
    {
        $userModel = new User();
        $userModel->where("user_type","seller");
        $result = $userModel->paginate($perPage,$columns,null,$perPage);
        return $result;
    }
}

write that when this method is called, the where condition will not take effect.

however, if you write the code in the paginate method directly into controller, the where condition will apply correctly.

what the hell is this for?

my code is not written in controller

Mar.30,2021

try this

        $userModel = new User();
        $query = $userModel->where('user_type','seller');
        $result = $query->paginate($perPage,$columns,null,$perPage);

in addition, I don't understand why I wrote it this way. Since I used PrettusRepository, I should follow the way this package is written.

this is why the paginate method of the base class BaseRepositoryApi directly fetches the data of User.

query builder in

Orm seems to be a single case

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb21f6-23a4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb21f6-23a4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?