A
A
Anatoly Sergeevich2017-05-09 15:55:00
Laravel
Anatoly Sergeevich, 2017-05-09 15:55:00

Recreating DBAL structure on Laravel ORM?

Good afternoon, there is a structure that I built on DBAL

DBAL::createQueryBuilder()
            ->select('u.id_read','n.id_user')
            ->from('news', 'n')
            ->leftJoin('n', 'user', 'u', 'u.id_read = n.id_user')
            ->where('u.id_user = ?')
            ->andWhere('n.created_at > u.created_at')
            ->setParameters([
                0       =>      1,
            ])
            ->execute()->rowCount()

I just have a problem only in ->andWhere('n.created_at > u.created_at') and I can't adjust it to Laravel ORM in any way.
$laravel = App\News::join('user', 'user.id_read', '=', 'news.id_user')
            ->where([
                ['user.id_user', '=', 1],
                ['news.created_at', '>', 'user.created_at']
            ])
            ->count();

It doesn't work at all like it worked on DBAL, help guys, maybe something is wrong.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question