nhayder
1 week ago

View Composer not finding blade file

Posted 1 week ago by nhayder

I have new component query on my comment.php model

public static function getNewComponent()
    {
    
        return static::with('user', 'article')

                ->where('status', '=', 1)

                ->orderBy('id', 'desc')
                
                ->paginate(10);

    }

on my App service provider i have this view composer that should keep the $newComments variable available every time the partials.comments.new is loaded.

unfortunately? this is working for me (* )

view()->composer('*', function($view){

    $view->with('newComments', Comment::getNewComponent());

});

this is returning error

view()->composer('partials.comments.new', function($view){

       $view->with('newComments', Comment::getNewComponent());

 });

this is the error

Undefined variable: newComments (View: /Applications/MAMP/htdocs/myapp/resources/views/admin/dashboard/dashboard.blade.php)

the URI partials.comments.new dose exist and i have blade partial available on the folder.

Any ideas what is going on .

Please sign in or create an account to participate in this conversation.