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); } }
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'); }
/** * 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]); }
public function destroy($id) { $fruit = Fruit::find($id); $fruit->delete(); return redirect('fruits')->with('message', 'Fruit deleted.'); }