DEV Community

loading...

How will I identify resource default url in laravel?

abdullahalnoor profile image Md Abdullah al noor ・1 min read

I am running this command for model, migration, resource controller.

php artisan make:model QuestionAnswer -mc -r ..
My Edit Function

public function edit(QuestionAnswer $questionAnswer)
{
// return $questionAnswer;
return view('backend.faq.edit',get_defined_vars());
}

Route one in web.php : Route::resource('faq','QuestionAnswerController'); in view : {{route('admin.faq.edit',$questionAnswer->id)}}

Route two in web.php : Route::resource('question-answer','QuestionAnswerController'); in view {{route('admin.question-answer.edit',$questionAnswer->id)}}

in Edit function for Route one : $questionAnswer object return null. but for Route two : $questionAnswer return object mean expected output ..

Follow this question

Question is there possible way to find out what exact url I will write ? .. like question-answer.. or command line ...or how will I figure it out ? I think there must be something..

How will I know I need to write question-answer this ? by default it works... when i write faq i need to change in edit function variable($faq) .

How will I know by default url (question-answer) will work ..when php artisan route:list command give us all route list.. and when I make model Category laravel create table name categories and follow grammar rules

Discussion

pic
Editor guide
Collapse
abdullahalnoor profile image
Md Abdullah al noor Author

After running auth command I find all route list … route:list by this command..
But after running this command php artisan make:model QuestionAnswer -mc -r I did not find QuestionAnswer model route list …
if i write in web.php this line Route::resource('question-answer','QuestionAnswerController'); everythink is okay but if I write in web.php : Route::resource('faq','QuestionAnswerController'); i need to change in edit function variable($faq) .

How will I know I need to write Route::resource('question-answer','QuestionAnswerController'); ?
how i will identify resource default url in laravel ?