public function store(Request $request) { $website = new Website(); $webRecords[] = ['name' => null, 'description' => null, 'url' => null]; //all website records $website_model[] = null; //loop on website $length = count($request->get('website')); //lets create a record foreach ($request->get('website') as $url) { $webRecords[] = $this->collectWebsiteData('website', '', $url); // every key has an arr except merchant_id } //loop on social $length = count($request->get('social')); // foreach ($request->get('social') as $url) { $webRecords[] = $this->collectWebsiteData('social', '', $url); // every key has an arr except merchant_id } //loop on ecommerce $length = count($request->get('ecom_site')); // foreach ($request->get('ecom_site') as $url) { $webRecords[] = $this->collectWebsiteData('ecom_site', '', $url); // every key has an arr except merchant_id } unset($webRecords[0]); foreach ($webRecords as $websiteSingleRecord) { $website_model[] = $website->create($websiteSingleRecord); } unset($website_model[0]); return $website_model; }
/** * Run the database seeds. * * @return void */ public function run() { // Website::create(['name' => 'HaloMalang', 'url' => 'http://halomalang.com', 'launched_at' => \Carbon\Carbon::parse('2012-03-01 00:00:00')]); }