ゆきしお全力カレンダー1日目 array_merge(): Argument #2 is not an arrayのエラーが起きた時にRoutes直したら解決した
ControllerからViewに値が渡らない時、以下のようなエラーが発生しました
'array_merge(): Argument #2 is not an array'
直し方
Controller
class PagesController extends Controller
{
public function index()
{
$name = [];
$name['first_name'] = 'Tetsuro';
return view("welcome", $name);
}
}
Routes
Route::get('/', function () {
return view('welcome', 'PagesController@index');
});
↓
第2引数に関数入れるのをやめる
Route::get('/', 'PagesConstroller@index');
解決しました!