guys following tuts tutorial laravel , since have installed laravel 5 couple of errors throwing .
code
public function getindex() { return view::make('categories.index') ->with('categories', category::all()); } this function throwing 2 errors
class 'app\http\controllers\category' not found class 'app\http\controllers\views' not found well know because of different name spacing in laravel 5 . 2nd error tried add
use view @ begining of file not finding view . can 1 let me know directory these files resides
thanks
both of not in controllers. view class apart of illuminate , other 1 class model created.
when use new class in php file must include or use it.
the way category class is"
use app\category should solve one.
your view 1 more difficult. if use ide can import classes easier don't have remember namespace / class name. however, if don't need know 1 use , when use it. in case need do:
use view should solve this.
so in controller above declaration , below namespace must put use calls
<?php namespace app\http\controllers // i'm removing because there way not have use this... // use view; use app\category; class yourcontroller extends controller { ... } like mentioned in comment there better way. use helper function view() return view same without doing view way doing it.
all have change is:
return view::make('categories.index')->with('categories', category::all()); to
return view('categories.index', ['categories' => category::all()]); or return view('categories.index')->with('categories',category::all()) removes confusion of messing classes.
Comments
Post a Comment