2

I could not think how to write question for this problem.

So this is my problem.

I have two views

store-side-menu.blade.php

<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a>

@foreach($store_categories as $cats)
    <a href="#">{{ $cats->category_of_store }}</a>
@endforeach

employ.blade.php

@section('side-menu-section')
  @include('fc.static.store-side-menu')
@endsection

In employ.blade.php is only includes the store-side-menu.blade.php. I have designed this structure due to need.

In controller I have

public function employment()
{
    $search = "";
    $store_categoies = Category::all();
    return view('fc.employ.employ', compact('search', 'store_categories'));
}

Now I have included store_categories in compact but store-side-menu.blade.php cannot access it. How do I achieve with its solution.

3
  • what error you are getting?? Commented Feb 12, 2017 at 12:11
  • Undefined variable: store_categories (View: C:\wamp64\www\FlashCart\resources\views\fc\static\store-side-menu.blade.php) Commented Feb 12, 2017 at 12:12
  • Please add the error to question. Commented Feb 12, 2017 at 16:11

1 Answer 1

1

Try the code below and you should be good to go:

@section('side-menu-section')
  @include('fc.static.store-side-menu', ['store_categories' => $store_categories])
@endsection
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.