Controller does not exist
Created 7 years ago by minkyovHello, I am developing a website and I need an ajax request that calls a function inside a class which retrieves some information that will be used further. I have the following structure in the project: ajax request: $.ajax({ type: "POST", url: './submit/fillSemester' ... }); web.php: Route::post('/submit/fillSemester', 'ChampionsController@fillSemester'); ChampionsController.class: namespace App\Http\Controllers; use Illuminate\Routing\Controller; class ChampionsController extends Controller {
public function index()
{
return view('home');
}
public function fillSemester(){
echo "window.alert('hey')";
}
} This class is found in app/http/controllers. When the value in a select tag is changed the ajax request is fired and supposed to route to the function in the controller but it instead says app/http/controllers/ChampionsController does not exist or throws a 500 error.
I'm a bit baffled because I think that everything for it to work is ready. Thank you for the help.
Try and indent your code using proper markdown please 😊
But when you designate your route you need to define the entire class string for the controller:
Route::post('/submit/fillSemester', 'App\Http\Controllers\ChampionsController@fillSemester');
But I would agree with @piterden that you would be better off wrapping this in an addon.
You should try to make addon for streams. And read the docs for Pyro. There are some different folders, if in few words. Try to make own theme for start:
Then look in
addons
folder to see the result. Any new addon in Pyro is like that namespaceapp
of native Laravel, where you wanted to put your controller. You could place inside any addon everything, what you want. See docs for detailed info.When you will finish it, try to make a module - this is much interesting, regarding to scaffold shuff:
I sure - you would love it!))
Examples are inside core folder.