Answer the question
In order to leave comments, you need to log in
How to solve the problem of passing data from controller to view?
Good evening gentlemen.
I can't figure out the logic behind the output.
In general, the picture is as follows:
There are several views
In one main view (index.blade.php) another view (my_menu.blade) is called.
In which the problem begins to be observed
I have localization and when I go to the page rishat.kg/ru/page-eng/change everything works fine.
But as soon as I want to make a transition to this page with a menu that is implemented in my_menu.blade, the problem with localization begins. Since just a link selected from the database is transmitted and the localization does not want to stick because there is no route : of the form: = {{ route('rusNewsShow',['slug'=>$item->slug]) }}"
I just can't figure out how to push this route without breaking {{ $item_c->url }} in which the link is fetched from the database - which is indicated in the admin panel.
Sources:
https://gist.github.com/Rishats/e69828fe248dd162c9...
Video (I described the problem as best I could :( )
https://www.youtube.com/watch?v=LKW67RQII4w&featur...
PS I feel what I call things not in their proper names.I would be glad if you correct it :)
UPD
my_menu.blade.php
@foreach($items as $item)
<li>
<a href="{{ $item->url }}">{{ $item->title }}</a>
@if($item->children)
<ul class="submenu">
@foreach($item->children as $item_c)
<li><a href="{{ $item_c->url }}">{{ $item_c->title }}</a></li>
@endforeach
</ul>
@endif
</li>
@endforeach]
Answer the question
In order to leave comments, you need to log in
My version:
// Routes
Route::group(['prefix' => LaravelLocalization::setLocale()], function() {
Route::get('/', '[email protected]');
Route::get('news/{id}', '[email protected]')->name('show.news');
Route::get('page/{slug}', '[email protected]')->name('show.page');
});
// Views
<a href="{{ app()->getLocale() . $item->url }}">{{ $item->title }}</a>
$table_name = 'pages_' . config('app.locale');
$pages = \DB::table($table_name)->get();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question