コード例 #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $status = array('active', 'inactive');
     for ($i = 0; $i < 10; $i++) {
         $publisher = new \App\Publisher();
         $publisher->name = 'publisher-' . $i;
         $publisher->status = $status[array_rand($status)];
         $publisher->save();
     }
 }
コード例 #2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = \Validator::make(\Input::all(), \App\Publisher::$rules);
     if ($validator->passes()) {
         $publisher = new \App\Publisher();
         $publisher->name = \Input::get('name');
         $publisher->save();
         flash('Publisher added.');
         return \Redirect::back();
     }
     return \Redirect::back()->withInput()->withErrors($validator);
 }