Basically I have 2 tables
- users
- relation
So what I want is when I enter my search query (username ) so it should search in my database using like function and then those users which listed after like
function should automatically check if myuserid
follows the listed user.id
from relation table.
Users table
Id |uid |username |pwd
Relation table
Id|folllwedbyid|followedtoid|ruid|rtd(timestamp)
relation.ruid
is like :
"$myid=7382;""users.id=7272 ""so relation.ruid =73827272"
DB::table('users')
->join('relation','relation.followetoid','=','users.id')
->whereNotIn('users.id',[$myid])
->select('users.id','users.username',DB::raw('(CASE WHEN relation.ruid = ' . $myid . ' users.id THEN 1 ELSE 0 END) AS is_user')
->get();