0

First of all, hello, and forgive me in a slightly worse English language

index.blade.php

  <div class="col-sm-6 col-xs-12">
            <div class="toolbar-tools pull-right">
                <ul class="nav navbar-right">
                    @if(Entrust::can('add_post'))
                        <li>
                            @foreach($main_title_options as $option)
                                <a href="{{ url('admin/post/create') }}" @if(isset($_GET['main_title']) && $_GET['main_title'] == $option->value)>

                                    <i class="fa fa-plus"></i>
                                    {{ trans('labels.create_' . $option->value   ) }}
                                    @else
                                        {{ trans('labels.create_posts') }}
                                    @endif
                                    @endforeach

                                </a>
                        </li>
                    @endif
                </ul>
            </div>
        </div>

main_title.blade.php

  <div class="form-group">
                    <label for="main_title">{{ trans('labels.main_title') }}</label>
                    <select v-model="post.main_title | mainTitle" name="main_title"
                            id="main_title"
                            class="form-control">
                        @foreach($main_title_options as $option)
                            <option {{ old('main_title') == $option->value ? 'selected="selected"' : '' }} value="{{ $option->value }}">
                                {{ trans('labels.'.$option->value) }}
                            </option>
                        @endforeach
                    </select>
                </div>

I want to, for example, if I come with http://nesto.test/admin/post?main_title=post, automatically select value is 'post', and if I come with http://nesto.test/admin/post?main_title=manifestacion , automatically select value will be 'manifestation'

I hope you understand what I want, thank you in advance

buzo
  • 11
  • 4

1 Answers1

0

If you want to use controller then this is a sample controller function in which we accept get variable in $request and pass it to view file

public function my_function(Request $request)
{
    //Put main_title in a variable
    $main_title = $request->main_title;

    //Pass main_title to view
    return view('yourview', compact('main_title'));
}

Or you can directly send get parameter to view from your route file

Route::get('/admin/post',function(Request $request)
{
    $main_title = $request->main_title;
    return view('yourview', compact('main_title'));
});

include Request ad the beginning of the file

use Illuminate\Http\Request;

Now you can access $main_title variable in view file like

<option {{ $main_title == $option->value ? 'selected="selected"' : '' }} value="{{ $option->value }}">

If you want more info refer this link

Vijay
  • 96
  • 9