public function run()
 {
     DB::table('items')->delete();
     $category = App\Category::where('name', '=', 'Food and drink')->first();
     App\Item::create(['name' => "Boag's Draught"])->categories()->attach($category->id);
     App\Item::create(['name' => "Crown Lager"])->categories()->attach($category->id);
     App\Item::create(['name' => "Toohey's Extra Dry"])->categories()->attach($category->id);
 }
Example #2
0
<?php

Route::group(['prefix' => 'awesomelist'], function () {
    get('', function () {
        return view('home');
    });
    get('items', function () {
        return App\Item::all();
    });
    post('items', function () {
        $item = App\Item::create(Request::all());
        return $item->id;
    });
    put('items/{id}', function ($id) {
        $item = App\Item::find($id);
        $item->completed = $item->completed ? false : true;
        $item->update();
    });
    delete('items/{id}', function ($id) {
        $item = App\Item::find($id);
        $item->delete();
    });
});