I created 3 composer views previously and they all work properly, but then I created another one, which doesn't seem to work. I've been trying to get it to work, it doesn't seem to be something related to my code. I will drop a piece of it here, but I still don't think it's the code.
Provider EvenComposerProvider:
public function register(){
$this->composeEven();
}
public function composeEven(){
view()->composer('includes.aklinkosesi', 'App\Http\Composers\EvenComposer');
}
Composer EvenComposer:
class EvenComposer{
public function compose(View $view){
$view->with('evens', Even::orderBy('id','desc')->paginate(10));
}
}
And than I included the provider inside app.php
App\Providers\EvenComposerProvider::class
When I try to loop through $evens
with the foreach
, it throws the error:
Undefined variable: evens
My rough guess will be that, Laravel does not compile app.php
So here is the solutions which might work for people in same sitatuin. First try these commands:
composer update
php artisan config:clear
php artisan cache:clear
composer dumpautoload
php artisan cache:clear
I tried a few of them than deleted bootstrap/cache/config
file and it worked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With