public function run() { DB::table('t_powerful')->delete(); $data = array('HTML 5', 'CSS3', 'Custom Typography', 'Responsive Design', 'Custom Fonts'); $desc = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s"; foreach ($data as $item) { Powerful::create(['name' => $item, 'icon' => 'public/images/icon.png', 'description' => $desc]); } }
/** * Store a newly created powerful in storage. * * @return Response */ public function store() { $rules = array('name' => 'required', 'icon' => 'image'); $validator = Validator::make($data = Input::all(), $rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } //upload powerful icon if (Input::hasFile('icon')) { $name = md5(time() . Input::file('icon')->getClientOriginalName()) . '.' . Input::file('icon')->getClientOriginalExtension(); $folder = "public/uploads/powerful"; Input::file('icon')->move($folder, $name); $path = $folder . '/' . $name; //update new path $data['icon'] = $path; } //save to database Powerful::create($data); return Redirect::route('admin.powerful.index')->with('message', 'Item had created!'); }