How to use Eloquent ORM of laravel to implement a complicated sql statement

SELECT t.*,u.`name` 
FROM template t 
INNER JOIN `user` u 
ON u.id = t.user_id
WHERE t.is_delete = 1 
AND ( t.title LIKE "%abc%" or u.`name` LIKE "%abc%" )

above are the sql statements I want to implement, and the model model relationships are all correct

.

what if it is paged on this basis

Mar.13,2021

Template::join('user', 'template.user_id', '=', 'user.id')
    ->where('is_delete', 1)
    ->where(function ($query) {
        $query->where('title', 'like', '%abc%')
            ->orWhere('user.name', 'like', '%abc%');
    })->skip(*(-1))->take()
    ->get();

you can try, it's written like this


paginate () or array_slice () handle it yourself

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-1e5dc86-44aae.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-1e5dc86-44aae.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?