i am trying updating a project from laravel 5.7 to 6.x
I have a multi language website and in the footer i have sleect box to change the language so the problem is that it gives the error:
Undefined variable: language
I have check the docs and i realy don't no what i am missing! https://laravel.com/docs/6.x/views
my footer:
<select class='form-control' id="language_footer" name="language">
foreach($language1 as $key => $value)
<option value="{{$key}}" {{ (Session::get('language') == $key) ? 'selected' : '' }} > {{$value}}</option>
@endforeach
</select>
This is my SetDataProvider
public function boot()
{
if(env('DB_DATABASE') != '') {
if(Schema::hasTable('language'))
$this->language();
}
}
public function language()
{
$language = Language::where('status', '=', 'Active')->pluck('name', 'short_name');
View::share('language', $language);
$default_language = Language::where('status', '=', 'Active')->where('default', '=', '1')->limit(1)->get();
View::share('default_language', $default_language);
if($default_language->count() > 0) {
Session::put('language', $default_language[0]->value);
App::setLocale($default_language[0]->value);
}
}
In the laravel 5.7 i have no problems and seems to work in laravel 6.x it says Undefined variable: language
Thnaks for your help.
So i am dumb!!!
I have forget to declare the SetDataProvider in app.conf
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.