Skip to main content
public function index()
{
  $store = Store::all(); // got this from database model
  
  return view('store')->with('store', $store); 
}

You've three options in general.

  1. return view('store')->with('store', $store);

  2. return view('store')->withStore($store);

  3. return view('store')->with(compact('store'));

1.Creates a variable named store which will be available in your view and stores the value in the variable $store in it.

2.Shorthand for the above one.

3.Also a short hand and it creates the same variable name as of the value passing one.

Now in your view you can access this variable using

{{ $store->name"">name }}

it will be same for all 3 methods.

public function index()
{
  $store = Store::all(); // got this from database model
  
  return view('store')->with('store', $store); 
}

You've three options in general.

  1. return view('store')->with('store', $store);

  2. return view('store')->withStore($store);

  3. return view('store')->with(compact('store'));

1.Creates a variable named store which will be available in your view and stores the value in the variable $store in it.

2.Shorthand for the above one.

3.Also a short hand and it creates the same variable name as of the value passing one.

Now in your view you can access this variable using

{{$store->name""

it will be same for all 3 methods.

public function index()
{
  $store = Store::all(); // got this from database model
  
  return view('store')->with('store', $store); 
}

You've three options in general.

  1. return view('store')->with('store', $store);

  2. return view('store')->withStore($store);

  3. return view('store')->with(compact('store'));

1.Creates a variable named store which will be available in your view and stores the value in the variable $store in it.

2.Shorthand for the above one.

3.Also a short hand and it creates the same variable name as of the value passing one.

Now in your view you can access this variable using

{{ $store->name }}

it will be same for all 3 methods.

public function index()
{
  $store = Store::all(); // got this from database model
  
  return view('store')->with('store', $store); 
}

You've three options in general.

  1. return view('store')->with('store', $store);

  2. return view('store')->withStore($store);

  3. return view('store')->with(compact('store'));

1st one creates1.Creates a variable named store which will be available in your view and stores the value in the variable $store in it.

2nd one is a shorthand2.Shorthand for the above one.

3rd one is also3.Also a short hand and it creates the same variable name as of the value passing one.

Now in your view you can access this variable using

{{$store->name""

it will be same for all 3 methods.

public function index()
{
  $store = Store::all(); // got this from database model
  
  return view('store')->with('store', $store); 
}

You've three options in general.

  1. return view('store')->with('store', $store);

  2. return view('store')->withStore($store);

  3. return view('store')->with(compact('store'));

1st one creates a variable named store which will be available in your view and stores the value in the variable $store in it.

2nd one is a shorthand for the above one.

3rd one is also a short hand and it creates the same variable name as of the value passing one.

Now in your view you can access this variable using

{{$store->name""

it will be same for all 3 methods.

public function index()
{
  $store = Store::all(); // got this from database model
  
  return view('store')->with('store', $store); 
}

You've three options in general.

  1. return view('store')->with('store', $store);

  2. return view('store')->withStore($store);

  3. return view('store')->with(compact('store'));

1.Creates a variable named store which will be available in your view and stores the value in the variable $store in it.

2.Shorthand for the above one.

3.Also a short hand and it creates the same variable name as of the value passing one.

Now in your view you can access this variable using

{{$store->name""

it will be same for all 3 methods.

added 285 characters in body
Source Link
Jilson Thomas
  • 7.3k
  • 29
  • 31
public function index()
{
  $store = Store::all(); // got this from database model
  
  return view('store')->with('store', $store); 
}

You've three options in general.

  1. return view('store')->with('store', $store);

  2. return view('store')->withStore($store);

  3. return view('store')->with(compact('store'));

1st one creates a variable named store which will be available in your view and stores the value in the variable $store in it.

2nd one is a shorthand for the above one.

3rd one is also a short hand and it creates the same variable name as of the value passing one.

Now in your view you can access this variable using

{{$store->name""

it will be same for all 3 methods.

public function index()
{
  $store = Store::all(); // got this from database model
  
  return view('store')->with('store', $store); 
}

You've three options in general.

  1. return view('store')->with('store', $store);

  2. return view('store')->withStore($store);

  3. return view('store')->with(compact('store'));

public function index()
{
  $store = Store::all(); // got this from database model
  
  return view('store')->with('store', $store); 
}

You've three options in general.

  1. return view('store')->with('store', $store);

  2. return view('store')->withStore($store);

  3. return view('store')->with(compact('store'));

1st one creates a variable named store which will be available in your view and stores the value in the variable $store in it.

2nd one is a shorthand for the above one.

3rd one is also a short hand and it creates the same variable name as of the value passing one.

Now in your view you can access this variable using

{{$store->name""

it will be same for all 3 methods.

Source Link
Jilson Thomas
  • 7.3k
  • 29
  • 31
Loading