コード例 #1
0
ファイル: SlidersSeeder.php プロジェクト: vytien/laravel-5
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // clear table
     sliders::truncate();
     // add 1st row
     sliders::create(['title' => 'Slider 1', 'image' => 'vt-1438854983.png', 'description' => 'Slider 1']);
     // add 2nd row
     sliders::create(['title' => 'Slider 2', 'image' => 'vt-1438855001.png', 'description' => 'Slider 2']);
     // add more rows
     sliders::create(['title' => 'Slider 3', 'image' => 'vt-1438855013.png', 'description' => 'Slider 3']);
     sliders::create(['title' => 'Slider 4', 'image' => 'vt-1438855025.png', 'description' => 'Slider 4']);
     sliders::create(['title' => 'Slider 5', 'image' => 'vt-1438855042.png', 'description' => 'Slider 5']);
 }
コード例 #2
0
 /**
  * Insert the specified resource in storage.
  *
  * @param Request $request        	
  * @param int $id        	
  * @return Response
  */
 public function insert(Request $request)
 {
     $rst = $request->all();
     // upload file
     $imageName = 'vt-' . time() . '.' . $rst['vtFile']->getClientOriginalExtension();
     $rst['vtFile']->move(base_path() . '/public/mulodo/images/slider/upload/', $imageName);
     // upload file
     // retrive data and save them into the table that model defining.
     $data = array('title' => $rst['txtTitle'], 'image' => $imageName, 'description' => $rst['txtDescription']);
     $response = sliders::create($data);
     if ($response) {
         return redirect()->back();
     }
 }
コード例 #3
0
ファイル: SliderController.php プロジェクト: vytien/laravel-5
 /**
  * Remove the specified resource from storage.
  *
  * @param int $id        	
  * @return Response
  */
 public function destroy($id)
 {
     $response = sliders::destroy($id);
     if ($response) {
         return redirect()->back();
     }
 }