php - Laravel 5.2 Eloquent multiple select preg_replace(): Parameter mismatch, pattern is string while replacement is an array -
i've seen multiple different answers question, none of keep use of form model binding. seems form submitting tags array, should string. ideas?
controller:
/** * save new news * * @param request $request * @return mixed */ public function store(newsrequest $request) { // create news object , save form data $news = news::create($request->all()); // rename image file , move public/images $image = $request->file('image'); $path = "/images/"; $ext = $image->getclientoriginalextension(); $name = str_random(12) . $ext; $image->move(public_path() . $path, $name); $news->image = $path . $name; // save new image path news object $news->save(); //associate sandbox, if not $news->sandboxes()->sync($request->input('sandboxes')); //populate news_tag pivot table chosen tags $news->tags()->sync($request->input('tags')); return redirect()->action('fp\newscontroller@index'); }
here's trace:
errorexception in helpers.php line 747: preg_replace(): parameter mismatch, pattern string while replacement array in helpers.php line 747 @ handleexceptions->handleerror('2', 'preg_replace(): parameter mismatch, pattern string while replacement array', '/home/greg/projects/code/sandboxserver/vendor/laravel/framework/src/illuminate/support/helpers.php', '747', array('search' => '\?', 'replace' => array('fafeafadfa', 'hgtshjnfxsnbdg', 'https://www.thing.com', '2016-11-12 21:30', array('1', '2'), 'gdsagasgbvsa', '<p>bgsagsghsghsgb</p>', object(uploadedfile), '2016-11-13 01:31:53', '2016-11-13 01:31:53'), 'subject' => 'insert `news` (`title`, `author`, `url`, `publish_at`, `tags`, `snippet`, `content`, `image`, `updated_at`, `created_at`) values (fafeafadfa, hgtshjnfxsnbdg, https://www.thing.com, 2016-11-12 21:30, ?, ?, ?, ?, ?, ?)', 'value' => array('1', '2'))) @ preg_replace('/\?/', array('1', '2'), 'insert `news` (`title`, `author`, `url`, `publish_at`, `tags`, `snippet`, `content`, `image`, `updated_at`, `created_at`) values (fafeafadfa, hgtshjnfxsnbdg, https://www.thing.com, 2016-11-12 21:30, ?, ?, ?, ?, ?, ?)', '1') in helpers.php line 747 @ str_replace_array('\?', array('fafeafadfa', 'hgtshjnfxsnbdg', 'https://www.thing.com', '2016-11-12 21:30', array('1', '2'), 'gdsagasgbvsa', '<p>bgsagsghsghsgb</p>', object(uploadedfile), '2016-11-13 01:31:53', '2016-11-13 01:31:53'), 'insert `news` (`title`, `author`, `url`, `publish_at`, `tags`, `snippet`, `content`, `image`, `updated_at`, `created_at`) values (fafeafadfa, hgtshjnfxsnbdg, https://www.thing.com, 2016-11-12 21:30, ?, ?, ?, ?, ?, ?)') in queryexception.php line 56 @ queryexception->formatmessage('insert `news` (`title`, `author`, `url`, `publish_at`, `tags`, `snippet`, `content`, `image`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array('fafeafadfa', 'hgtshjnfxsnbdg', 'https://www.thing.com', '2016-11-12 21:30', array('1', '2'), 'gdsagasgbvsa', '<p>bgsagsghsghsgb</p>', object(uploadedfile), '2016-11-13 01:31:53', '2016-11-13 01:31:53'), object(pdoexception)) in queryexception.php line 39 @ queryexception->__construct('insert `news` (`title`, `author`, `url`, `publish_at`, `tags`, `snippet`, `content`, `image`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array('fafeafadfa', 'hgtshjnfxsnbdg', 'https://www.thing.com', '2016-11-12 21:30', array('1', '2'), 'gdsagasgbvsa', '<p>bgsagsghsghsgb</p>', object(uploadedfile), '2016-11-13 01:31:53', '2016-11-13 01:31:53'), object(pdoexception)) in connection.php line 730 @ connection->runquerycallback('insert `news` (`title`, `author`, `url`, `publish_at`, `tags`, `snippet`, `content`, `image`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array('fafeafadfa', 'hgtshjnfxsnbdg', 'https://www.thing.com', '2016-11-12 21:30', array('1', '2'), 'gdsagasgbvsa', '<p>bgsagsghsghsgb</p>', object(uploadedfile), '2016-11-13 01:31:53', '2016-11-13 01:31:53'), object(closure)) in connection.php line 685 @ connection->run('insert `news` (`title`, `author`, `url`, `publish_at`, `tags`, `snippet`, `content`, `image`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array('fafeafadfa', 'hgtshjnfxsnbdg', 'https://www.thing.com', '2016-11-12 21:30', array('1', '2'), 'gdsagasgbvsa', '<p>bgsagsghsghsgb</p>', object(uploadedfile), '2016-11-13 01:31:53', '2016-11-13 01:31:53'), object(closure)) in connection.php line 458 @ connection->statement('insert `news` (`title`, `author`, `url`, `publish_at`, `tags`, `snippet`, `content`, `image`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array('fafeafadfa', 'hgtshjnfxsnbdg', 'https://www.thing.com', '2016-11-12 21:30', array('1', '2'), 'gdsagasgbvsa', '<p>bgsagsghsghsgb</p>', object(uploadedfile), '2016-11-13 01:31:53', '2016-11-13 01:31:53')) in connection.php line 414 @ connection->insert('insert `news` (`title`, `author`, `url`, `publish_at`, `tags`, `snippet`, `content`, `image`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array('fafeafadfa', 'hgtshjnfxsnbdg', 'https://www.thing.com', '2016-11-12 21:30', array('1', '2'), 'gdsagasgbvsa', '<p>bgsagsghsghsgb</p>', object(uploadedfile), '2016-11-13 01:31:53', '2016-11-13 01:31:53')) in processor.php line 32 @ processor->processinsertgetid(object(builder), 'insert `news` (`title`, `author`, `url`, `publish_at`, `tags`, `snippet`, `content`, `image`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array('fafeafadfa', 'hgtshjnfxsnbdg', 'https://www.thing.com', '2016-11-12 21:30', array('1', '2'), 'gdsagasgbvsa', '<p>bgsagsghsghsgb</p>', object(uploadedfile), '2016-11-13 01:31:53', '2016-11-13 01:31:53'), 'id') in builder.php line 2107 @ builder->insertgetid(array('fafeafadfa', 'hgtshjnfxsnbdg', 'https://www.thing.com', '2016-11-12 21:30', array('1', '2'), 'gdsagasgbvsa', '<p>bgsagsghsghsgb</p>', object(uploadedfile), '2016-11-13 01:31:53', '2016-11-13 01:31:53'), 'id') @ call_user_func_array(array(object(builder), 'insertgetid'), array(array('title' => 'fafeafadfa', 'author' => 'hgtshjnfxsnbdg', 'url' => 'https://www.thing.com', 'publish_at' => '2016-11-12 21:30', 'tags' => array('1', '2'), 'snippet' => 'gdsagasgbvsa', 'content' => '<p>bgsagsghsghsgb</p>', 'image' => object(uploadedfile), 'updated_at' => '2016-11-13 01:31:53', 'created_at' => '2016-11-13 01:31:53'), 'id')) in builder.php line 1423 @ builder->__call('insertgetid', array(array('title' => 'fafeafadfa', 'author' => 'hgtshjnfxsnbdg', 'url' => 'https://www.thing.com', 'publish_at' => '2016-11-12 21:30', 'tags' => array('1', '2'), 'snippet' => 'gdsagasgbvsa', 'content' => '<p>bgsagsghsghsgb</p>', 'image' => object(uploadedfile), 'updated_at' => '2016-11-13 01:31:53', 'created_at' => '2016-11-13 01:31:53'), 'id')) in model.php line 1628 @ model->insertandsetid(object(builder), array('title' => 'fafeafadfa', 'author' => 'hgtshjnfxsnbdg', 'url' => 'https://www.thing.com', 'publish_at' => '2016-11-12 21:30', 'tags' => array('1', '2'), 'snippet' => 'gdsagasgbvsa', 'content' => '<p>bgsagsghsghsgb</p>', 'image' => object(uploadedfile), 'updated_at' => '2016-11-13 01:31:53', 'created_at' => '2016-11-13 01:31:53')) in model.php line 1597 @ model->performinsert(object(builder), array()) in model.php line 1488 @ model->save() in model.php line 574 @ model::create(array('_token' => 'dz4mgabuxpsv2fyt4rycatpecondvkjl0rx9tx9b', 'title' => 'fafeafadfa', 'author' => 'hgtshjnfxsnbdg', 'url' => 'https://www.thing.com', 'publish_at' => '2016-11-12 21:30', 'sandboxes' => array('1'), 'tags' => array('1', '2'), 'snippet' => 'gdsagasgbvsa', 'content' => '<p>bgsagsghsghsgb</p>', 'image' => object(uploadedfile))) in newscontroller.php line 56 @ newscontroller->store(object(newsrequest)) @ call_user_func_array(array(object(newscontroller), 'store'), array(object(newsrequest))) in controller.php line 80 @ controller->callaction('store', array(object(newsrequest))) in controllerdispatcher.php line 146 @ controllerdispatcher->call(object(newscontroller), object(route), 'store') in controllerdispatcher.php line 94 @ controllerdispatcher->illuminate\routing\{closure}(object(request)) @ call_user_func(object(closure), object(request)) in pipeline.php line 52 @ pipeline->illuminate\routing\{closure}(object(request)) @ call_user_func(object(closure), object(request)) in pipeline.php line 102 @ pipeline->then(object(closure)) in controllerdispatcher.php line 96 @ controllerdispatcher->callwithinstack(object(newscontroller), object(route), object(request), 'store') in controllerdispatcher.php line 54 @ controllerdispatcher->dispatch(object(route), object(request), 'app\http\controllers\fp\newscontroller', 'store') in route.php line 174 @ route->runcontroller(object(request)) in route.php line 140 @ route->run(object(request)) in router.php line 724 @ router->illuminate\routing\{closure}(object(request)) @ call_user_func(object(closure), object(request)) in pipeline.php line 52 @ pipeline->illuminate\routing\{closure}(object(request)) in authenticate.php line 51 @ authenticate->handle(object(request), object(closure)) @ call_user_func_array(array(object(authenticate), 'handle'), array(object(request), object(closure))) in pipeline.php line 136 @ pipeline->illuminate\pipeline\{closure}(object(request)) @ call_user_func(object(closure), object(request)) in pipeline.php line 32 @ pipeline->illuminate\routing\{closure}(object(request)) in verifycsrftoken.php line 64 @ verifycsrftoken->handle(object(request), object(closure)) @ call_user_func_array(array(object(verifycsrftoken), 'handle'), array(object(request), object(closure))) in pipeline.php line 136 @ pipeline->illuminate\pipeline\{closure}(object(request)) @ call_user_func(object(closure), object(request)) in pipeline.php line 32 @ pipeline->illuminate\routing\{closure}(object(request)) in shareerrorsfromsession.php line 49 @ shareerrorsfromsession->handle(object(request), object(closure)) @ call_user_func_array(array(object(shareerrorsfromsession), 'handle'), array(object(request), object(closure))) in pipeline.php line 136 @ pipeline->illuminate\pipeline\{closure}(object(request)) @ call_user_func(object(closure), object(request)) in pipeline.php line 32 @ pipeline->illuminate\routing\{closure}(object(request)) in addqueuedcookiestoresponse.php line 37 @ addqueuedcookiestoresponse->handle(object(request), object(closure)) @ call_user_func_array(array(object(addqueuedcookiestoresponse), 'handle'), array(object(request), object(closure))) in pipeline.php line 136 @ pipeline->illuminate\pipeline\{closure}(object(request)) @ call_user_func(object(closure), object(request)) in pipeline.php line 32 @ pipeline->illuminate\routing\{closure}(object(request)) in encryptcookies.php line 59 @ encryptcookies->handle(object(request), object(closure)) @ call_user_func_array(array(object(encryptcookies), 'handle'), array(object(request), object(closure))) in pipeline.php line 136 @ pipeline->illuminate\pipeline\{closure}(object(request)) @ call_user_func(object(closure), object(request)) in pipeline.php line 32 @ pipeline->illuminate\routing\{closure}(object(request)) @ call_user_func(object(closure), object(request)) in pipeline.php line 102 @ pipeline->then(object(closure)) in router.php line 726 @ router->runroutewithinstack(object(route), object(request)) in router.php line 699 @ router->dispatchtoroute(object(request)) in router.php line 675 @ router->dispatch(object(request)) in kernel.php line 246 @ kernel->illuminate\foundation\http\{closure}(object(request)) @ call_user_func(object(closure), object(request)) in pipeline.php line 52 @ pipeline->illuminate\routing\{closure}(object(request)) in shareerrorsfromsession.php line 49 @ shareerrorsfromsession->handle(object(request), object(closure)) @ call_user_func_array(array(object(shareerrorsfromsession), 'handle'), array(object(request), object(closure))) in pipeline.php line 136 @ pipeline->illuminate\pipeline\{closure}(object(request)) @ call_user_func(object(closure), object(request)) in pipeline.php line 32 @ pipeline->illuminate\routing\{closure}(object(request)) in startsession.php line 64 @ startsession->handle(object(request), object(closure)) @ call_user_func_array(array(object(startsession), 'handle'), array(object(request), object(closure))) in pipeline.php line 136 @ pipeline->illuminate\pipeline\{closure}(object(request)) @ call_user_func(object(closure), object(request)) in pipeline.php line 32 @ pipeline->illuminate\routing\{closure}(object(request)) in checkformaintenancemode.php line 44 @ checkformaintenancemode->handle(object(request), object(closure)) @ call_user_func_array(array(object(checkformaintenancemode), 'handle'), array(object(request), object(closure))) in pipeline.php line 136 @ pipeline->illuminate\pipeline\{closure}(object(request)) @ call_user_func(object(closure), object(request)) in pipeline.php line 32 @ pipeline->illuminate\routing\{closure}(object(request)) @ call_user_func(object(closure), object(request)) in pipeline.php line 102 @ pipeline->then(object(closure)) in kernel.php line 132 @ kernel->sendrequestthroughrouter(object(request)) in kernel.php line 99 @ kernel->handle(object(request)) in index.php line 53 @ require_once('/home/greg/projects/code/sandboxserver/public/index.php') in server.php line 21
really simple answer, had tags field inside of "news" eloquent model since our previous team had tags table column >.> . fixed once removed it!
Comments
Post a Comment