/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $validator = Validator::make($request->all(), $this->rules); if ($validator->passes()) { $customer = new Customer(); $customer->name = htmlspecialchars($request->input('name')); $customer->phoneMob = htmlspecialchars($request->input('phoneMob')); $customer->address = htmlspecialchars($request->input('address')); $customer->cardNo = htmlspecialchars($request->input('cardNo')); $customer->cardExpiry = htmlspecialchars($request->input('year') + "-" + $request->input('month')); $customer->cardHolder = htmlspecialchars($request->input('cardHolder')); $customer->cardCcv = htmlspecialchars($request->input('cardCcv')); $customer->save(); return Redirect::to('customers'); } else { return Redirect::action('CustomerController@create')->withErrors($validator); } }
/** * Run the database seeds. * * @return void */ public function run() { $customer = new Customer(); $customer->name = "John Doe"; $customer->address = '56 James Street, Brisbane, 4000'; $customer->phoneMob = '0495465134'; $customer->cardNo = 1234567890123456; $customer->cardExpiry = '2017-12'; $customer->cardHolder = 'John Be Doe'; $customer->cardCcv = 123; $customer->save(); $customer = new Customer(); $customer->name = "Alison Bass"; $customer->phoneMob = '0468795345'; $customer->address = '57 Wright Street, Cooroy Moutain, 4563'; $customer->cardNo = 1234567890123456; $customer->cardExpiry = '2017-09'; $customer->cardHolder = 'Alison Ann Bass'; $customer->cardCcv = 321; $customer->save(); }