/** * Run the database seeds. * * @return void */ public function run() { $data = $this->csv_to_array(base_path() . '/database/seeds/csv_files/payment_processors.csv'); foreach ($data as $d) { $url = $d['url']; try { $meta = new WebsiteMeta($url); $payment_processor = new PaymentProcessor(['name' => $d['name'], 'url' => $url, 'meta_title' => $meta->title(), 'meta_description' => $meta->description(), 'meta_keywords' => $meta->keywords()]); $payment_processor->save(); } catch (Exception $e) { error_log($e->getMessage() . "<br>" . 'The URL "' . $url . '" does not exist or is experiencing technical issues.'); } } }
/** * Store a newly created payment processor in storage. * * @return Response */ public function store() { //Validate form input used for creating payment processor. $validator = Validator::make(Input::all(), PaymentProcessorValidator::validationRulesNew()); // Redirect to pre-populated form if validation failed. if ($validator->fails()) { return Redirect::to('/admin/payment_processors/create')->withErrors($validator)->withInput(Input::all()); } // If validation passes, use form data to store // payment processor. $paymentProcessor = new PaymentProcessor(); $paymentProcessor->fill(Input::all()); $paymentProcessor->save(); Session::flash('success_message', 'The payment processor has successfully been created and stored!'); return Redirect::to('/payment_processors/' . $paymentProcessor->slug); }