exception - Laravel: Class 'CategoryModel' not found. How to access a model inside a sub-folder? -
my categorymodel
works when place inside models
folder. when place inside sub-folder user
. throws above error.
the model being called inside controller shown..
public function home() { // titling $data['title'] = "price soldier - home"; // controlling $data['current_category'] = "cellphones"; $data['current_brand'] = "all"; $data['current_sorting'] = "latest"; $data['categories'] = categorymodel::get_all_categories(); $data['brands'] = brandmodel::get_all_brands_by_category("cellphones"); $data['latests'] = productmodel::get_products("cellphones", "all", "latest"); $data['mvs'] = productmodel::get_products("cellphones", "all", "most viewed"); $data['plths'] = productmodel::get_products("cellphones", "all", "price low high"); $data['phtls'] = productmodel::get_products("cellphones", "all", "price high high"); // viewing return view::make("pages.user.home", $data); }
so, in simple terms, how can access model inside sub folder?
execute on command line:
composer dump-autoload
or
composer dump-autoload -o composer dumpautoload -o (dash optional)
for better optimization , speed.
every time use class in php must be:
1) required (you can in code, shouldn't); or
2) autoloaded (composer you).
or else give error you're looking at.
Comments
Post a Comment