示例#1
0
 public function run()
 {
     DB::table('fruits')->delete();
     $fruits = [["name" => 'Mango', "color" => 'Orange', "taste" => 'Sweet'], ["name" => 'Lime', "color" => 'Lime', "taste" => 'Sour']];
     foreach ($fruits as $s) {
         Fruit::create($s);
     }
 }
示例#2
0
 public function postUpdate($id)
 {
     $fruit = Fruit::find($id);
     $fruit->name = Input::get('name');
     $fruit->color = Input::get('color');
     $fruit->taste = Input::get('taste');
     $fruit->save();
     return Redirect::to('fruit');
 }
示例#3
0
 /**
  * Test destroy button deletes object from database.
  *
  * @return void
  */
 public function testDestroyButton()
 {
     Session::start();
     $fruit = factory(App\Fruit::class)->create();
     $param = ['_token' => csrf_token()];
     $this->seeInDatabase('fruits', ['identity' => $fruit->identity]);
     $id = \App\Fruit::whereIdentity($fruit['identity'])->first()->id;
     $this->action('DELETE', 'Fruits@destroy', ['id' => $id] + $param);
     $this->dontSeeInDatabase('fruits', ['identity' => $fruit->identity]);
 }
示例#4
0
 public function destroy($id)
 {
     $fruit = Fruit::find($id);
     $fruit->delete();
     return redirect('fruits')->with('message', 'Fruit deleted.');
 }