1

i have a very simple route code

Route::get("/{id}",function($id){
return view("post.posts",$id);});

and a simple code in the view:

<div><h1> hello .{{$id}} </h1></div>

but i get an exception: ErrorException in Factory.php line 167:array_merge(): Argument #2 is not an array

1 Answer 1

2

You need to pass array to your view, so instead of

Route::get("/{id}",function($id) {
    return view("post.posts",$id);
});

where you just pass string, you should use:

Route::get("/{id}",function($id) {
    return view("post.posts", ['id' => $id]);
});

or alternatively:

Route::get("/{id}",function($id) {
    return view("post.posts", compact('id'));
});
Sign up to request clarification or add additional context in comments.

1 Comment

@AliEl-Boghdady Glad I could help

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.