Vice President of Development at TouchStorm, LLC



1 Best Reply Awards

  • Member Since 3 Years Ago
  • 236 Lessons Completed
  • 3 Favorites

7th September, 2018

seomike left a reply on Poor WhereHas Performance • 1 month ago

I'm on Amazon RDS xxlarge with plenty of RAM. The issue is how Eloquent does its query for whereHas(). it does a full table scan on the model that calls it. Our table was 21.5 million rows, I could go pop popcorn, eat it and come back and the query would still be running...

$channel = Channel::find(1); // 21.5 million rows in table
$videos = $channel->whereHas('videos', function($query) {
        $query->where('status', 1); // << should only be 1300 videos back. :/

If we ran EXPLAIN on the query that hangs

EXPLAIN select * from `channel` 
where exists (select * from `video` inner join `channel_video` on `video`.`id` = `channel_video`.`video_id` where `channel`.`id` = `channel_video`.`channel_id` and `status` = 1) 

We saw where it is doing a full table lookup on Channel.

So on the Videos model we just added an Anonymous scope builder.

class Channels extends Model

      public function videos()
    return $this->belongsToMany(Videos::class, 'channel_video', 'channel_id', 'video_id');


class Videos extends Model { protected static function boot() { parent::boot();

    static::addGlobalScope('live', function (Builder $builder) {
        $builder->where('status', 1); // Speed up the belongsToMany!!!


$channel = Channel::find(1); // 21.5 million rows in table $videos = $channel->videos()->get(); // fast belongsToMany :D

4th October, 2017

seomike left a reply on How Do I Switch To Bootstrap 4 In Laravel 5.5? • 1 year ago

After install, there have been a lot of people having an issue with Popper.js not being included. If you still have trouble getting the Popper.js dependency working you can add this window.Popper = require('popper.js').default; above the require('bootstrap') to your resources/assets/js/app.js file.

Then run npm run dev or gulp to generate your new .css and .js files

Hat tip:

31st August, 2016

seomike left a reply on Best Practice For Handling "active" Menu Item In L5 • 2 years ago

#Dynamic Bootstrap Active Menu Items

Solved this using View Composers



This uses named routes to (as => '...') as a means to generate the

  • tags with links for Bootstrap
  • 2nd April, 2015

    seomike left a reply on Cant Composer Update • 3 years ago

    Making a cache dir in /bootstrap fixed this for me.

    Edit Your Profile

    Want to change your profile photo? We pull from