Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid argument supplied for foreach() (View: /var/www/html/resources/views/vendor/forum/category/index.blade.php) #154

Closed
LakshmanKatragadda opened this issue Oct 8, 2016 · 14 comments

Comments

@LakshmanKatragadda
Copy link

LakshmanKatragadda commented Oct 8, 2016

i followed bellow instructions

1.composer require riari/laravel-forum:~3.0

2.Then add the service provider to your config/app.php:
Riari\Forum\ForumServiceProvider::class,

3.composer require riari/laravel-forum-frontend:~1.0
Riari\Forum\Frontend\ForumFrontendServiceProvider::class,

4.php artisan vendor:publish

5.php artisan migrate

6.then click on mydomaiin.com/forum

i got a this error

Invalid argument supplied for foreach() (View: /var/www/html/resources/views/vendor/forum/category/index.blade.php)

in Category_controller you guys are mention columns name 'category_id ' but in db table only 'id ' column there .any reason for that ?

@Riari
Copy link
Collaborator

Riari commented Oct 8, 2016

The category_id column does exist and it's used to specify which category a category belongs to, if any.

Which version of Laravel are you using?

@LakshmanKatragadda
Copy link
Author

LakshmanKatragadda commented Oct 8, 2016

laravel 5.2.* some fields are not created at time of migration ex: category_id,description,private ... why ? and one more thing **i have already users table in my db ** .so at migration time its showing error users table already exits

@Riari
Copy link
Collaborator

Riari commented Oct 8, 2016

Sorry, I can't reproduce the issue with Laravel 5.2 / laravel-forum ~3.0 / laravel-forum-frontend ~1.0. Is your setup completely fresh or is it an upgrade from an older Laravel or laravel-forum version?

@Riari
Copy link
Collaborator

Riari commented Oct 10, 2016

i have already users table in my db ** .so at migration time its showing error **users table already exits

Nothing to do with this package. It doesn't create any user tables.

@LakshmanKatragadda
Copy link
Author

LakshmanKatragadda commented Oct 13, 2016

setup completely fresh and Laravel 5.2 / laravel-forum ~3.0 / laravel-forum-frontend ~1.0

@watchwood
Copy link

Ran into the exact same problem. Persists when I manually enter an initial category into the database.

Laravel 5.4 / laravel-forum ~4.0 / laravel-forum-frontend ~1.0

@watchwood
Copy link

The following gets popped into the laravel.log file when it happens:

[2017-02-04 19:13:11] local.ERROR: ReflectionException: Class forum.api.auth does not exist in C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Container\Container.php:681
Stack trace:
#0 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Container\Container.php(681): ReflectionClass->__construct('forum.api.auth')
#1 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Container\Container.php(565): Illuminate\Container\Container->build('forum.api.auth')
#2 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(702): Illuminate\Container\Container->make('forum.api.auth')
#3 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(138): Illuminate\Foundation\Application->make('forum.api.auth')
#4 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#5 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#6 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Routing\Router.php(561): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#7 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Routing\Router.php(520): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#8 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Routing\Router.php(498): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#9 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php(221): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#10 C:\git\seapowers\vendor\riari\laravel-forum\src\API\Dispatcher.php(132): Illuminate\Support\Facades\Facade::__callStatic('dispatch', Array)
#11 C:\git\seapowers\vendor\riari\laravel-forum\src\API\Dispatcher.php(83): Riari\Forum\API\Dispatcher->dispatch()
#12 C:\git\seapowers\vendor\riari\laravel-forum-frontend\src\Http\Controllers\CategoryController.php(21): Riari\Forum\API\Dispatcher->get()
#13 [internal function]: Riari\Forum\Frontend\Http\Controllers\CategoryController->index(Object(Illuminate\Http\Request))
#14 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Routing\Controller.php(55): call_user_func_array(Array, Array)
#15 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php(44): Illuminate\Routing\Controller->callAction('index', Array)
#16 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Routing\Route.php(203): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Riari\Forum\Frontend\Http\Controllers\CategoryController), 'index')
#17 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Routing\Route.php(160): Illuminate\Routing\Route->runController()
#18 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Routing\Router.php(559): Illuminate\Routing\Route->run()
#19 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(30): Illuminate\Routing\Router->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#20 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\VerifyCsrfToken.php(65): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#21 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(148): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#22 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#23 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\View\Middleware\ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#24 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(148): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#25 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#26 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Session\Middleware\StartSession.php(64): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#27 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(148): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#28 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#29 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#30 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(148): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#31 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#32 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Cookie\Middleware\EncryptCookies.php(59): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#33 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(148): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#34 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#35 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#36 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Routing\Router.php(561): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#37 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Routing\Router.php(520): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#38 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Routing\Router.php(498): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#39 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(174): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#40 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http{closure}(Object(Illuminate\Http\Request))
#41 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#42 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(148): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#43 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Routing\Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))
#44 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))
#45 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(149): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#46 C:\git\seapowers\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#47 C:\git\seapowers\public\index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#48 {main}

@watchwood
Copy link

I fixed the problem by explicitly adding your forum api middleware to the application's route middleware in the Kernel. You should probably make a note of that in your documentation.

@Riari
Copy link
Collaborator

Riari commented Feb 5, 2017

4.0 is supposed to register the middleware automatically from the service provider if the routing option is enabled (which it is by default). Seems like this might be a compatibility issue with Laravel 5.4. I'll test it soon.

@TheShakyCoder
Copy link

TheShakyCoder commented Feb 6, 2017

@watchwood same problem. Just found the error 'Class forum.api.auth does not exist'. What did you put in your Kernel exactly?

@watchwood
Copy link

@SierraKilo

    protected $routeMiddleware = [
		// other stuff here
		'forum.api.auth' => \Riari\Forum\Http\Middleware\APIAuth::class,
    ];

@watchwood
Copy link

watchwood commented Feb 10, 2017

@Riari It also appears that observers aren't working correctly in the stack that I have. Thread/Post counts aren't incrementing at all.

edit: And it's not letting me delete threads out of the box, either.

@Riari
Copy link
Collaborator

Riari commented Feb 11, 2017

I have just pushed a few releases - one with the latest PRs, and one that fixes the Middleware issue in Laravel 5.4 (it's because the Illuminate\Routing\Router middleware() method has been renamed to aliasMiddleware()). Since you've fixed it in your code already, you don't need to upgrade unless you want the new stuff in 4.0.2.

I could not reproduce the observer or thread deletion issues. For the latter, make sure your policy is set up to allow deleting (the policies are purposefully very restrictive by default).

@stormhillmedia
Copy link

I just loaded the package today and had the same issue and solution as @watchwood.

@Riari Riari closed this as completed Jan 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants