Read more about Eager Loading, well, with method is to Eager Load your relationships
can you explain the with() method?
When doing something like:
return redirect('/')->with('success', 'item created');
What is the with() method? In this case, it isn't an Eloquent command (or is it?). I understand command chaining, but am not sure what the with() method is. I am not finding this in the Laravel docs.
TIA
It depends on how you use the with method and on what class. For example when you call the method redirect() the class \Illuminate\Http\RedirectResponse is used. This method has a with function that will add a key value item to the session for that redirect.
Documentation: https://laravel.com/api/5.6/Illuminate/Http/RedirectResponse.html#method_with
However, when you use the with method on the view() method it will add a key and value item to the view. This way you can use that variable in your blade files
Documentation: https://laravel.com/api/5.6/Illuminate/View/View.html#method_with
So the with method is used on multiple places, but it depends on the class you call it on!
Please or to participate in this conversation.