5
Good morning Sirs. I have a question about the route in the Laravel, I carried through researches trying to find the result but I did not find what I wanted.
I need that from the id that is redirected (for example: /discipline/3) it sends the number "3" to the parameter of my method return_discipline($id) so I can work with it. I tried to do as below but nothing worked so far. What should I do?
Thank you
Code in web.php file
Route::get('/disciplina/{id}', "select@retorna_disciplina(id)")->middleware('login');
Code in the controller
public function retorna_disciplina($id)
{
$prontuario = session('prontuario');
$cargo = session('cargo');
if($cargo == "P")
{
$disciplina = DB::table('oferecimento_disciplina')
->where('id_professor','=', $prontuario)
->where('dsa', '=', $id)
->first();
if(count($disciplina)>0)
{
$postagens = DB::table('postagens')
->where('dsa', '=', $id)
->get();
return view('disciplinas.disciplina')->with([
'disciplina' => $disciplina,
'postagens' => $postagens
]);
}
else{
Redirect::to('/perfil')->withErros("A disciplina não existe ou você não tem permissão de acesso");
}
}
}
What is the version of your Laravel?
– novic