Hello Ilhm,
Next time try to place the code in a code block, then it is more readable :)
The error is indeed that the $countries variable doesn't exist. You should give it to the view on the place where you create the view.
Example:
public function create()
{
// an example, I suspect you can load it from the database or a config file
$countriesList = [
'Afghanistan',
'Albania',
'Algeria',
];
return view('contact.create')
->with('countries', $countriesList) // this is the place where you create a $countries variable in your view with the content of $countriesList. They can have the same name but to make the example clear I use 2 different names.
;
}
You can also do
return view('contact.create', ['countries' => $countriesList]);
See the documentation: https://laravel.com/docs/6.x/blade#displaying-data
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community