Issue
I would like to query my visitors records from my visitors table that has the the OS substring of bot
.
As you can see, there are 3 of 8 records listed here right now. I just want to grab those 3.
I tried look in this documentation. I didn't really find what I am looking to do there, unless I missed it.
$visitors = Visitor::orderBy('created_at', 'desc')
->where('os',substr('bot'))<----- NEED help here
->get();
Update
I believe my question is not a duplicate of this proposed duplicate.
Solution
Did you try with 'LIKE'
$visitors = Visitor::orderBy('created_at', 'desc')
->where('os', 'like', '%bot%') //<----- Match any word containing ...bot.. at any place
->get();
Using a variable
$visitors = Visitor::orderBy('created_at', 'desc')
->where('os', 'like', '%'. $bot .'%') //<----- Match the searched variable
->get();
Answered By - EddyTheDove
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.