laracasts / Lets-Build-a-Forum-in-Laravel

http://laracasts.com/series/lets-build-a-forum-with-laravel
915 stars 309 forks source link

Channels dropdown doesn't show channels anymore #8

Closed kasperpeulen closed 7 years ago

kasperpeulen commented 7 years ago

image

kasperpeulen commented 7 years ago

I think now I understand:

      \View::composer('*', function ($view) {
            $channels = \Cache::rememberForever('channels3', function () {
                $channels = Channel::all();
                return $channels;
            });

            $view->with('channels', $channels);
        });

My database was not seeded when I started this project, so my channels will now (forever?) be empty. Because dd($channels) give an empty collection. Can I reset this cache somehow?

n1crack commented 7 years ago

You can call 'php artisan cache:clear'

or you can listen eloquent model events


public static function boot()
    {
        parent::boot();
        static::created(function ($model)
        {
            // Clear Cache commands
        });
    }