Thursday, March 2, 2017

Query only records that match specific substring - Laravel 5

I would like to query my visitors records from my visitors table that has the the OS substring of bot.

enter image description here

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 here https://laravel.com/docs/5.4/queries

I didn't really what I am looking to do there, unless I missed it.

$visitors = Visitor::orderBy('created_at', 'desc')
        ->where('os',substr('bot'))<----- STUCK
        ->get();

Any hints / suggestions on this will be much appreciated !



via ihue

Advertisement