filter items by event in Controller

This commit is contained in:
j3d1 2019-12-02 18:41:40 +01:00
parent f5725cfde7
commit b978b2bc0b
3 changed files with 7 additions and 7 deletions

View file

@ -22,5 +22,5 @@ class Container extends Model
* *
* @var array * @var array
*/ */
protected $hidden = ['created_at','updated_at']; protected $hidden = ['created_at', 'deleted_at', 'updated_at'];
} }

View file

@ -3,6 +3,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Item; use App\Item;
use App\Event;
use Illuminate\Http\Request; use Illuminate\Http\Request;
class ItemController extends Controller class ItemController extends Controller
@ -15,12 +16,14 @@ class ItemController extends Controller
public function showByEvent($event) public function showByEvent($event)
{ {
return response()->json(Item::byEvent($event)); $eid = Event::where('slug','=',$event)->first()->eid;
return response()->json(Item::where('eid','=',$eid)->get());
} }
public function searchByEvent($event, $query) public function searchByEvent($event, $query)
{ {
return response()->json(Item::byEvent($event)); //TODO actually search $eid = Event::where('slug','=',$event)->first()->eid;
return response()->json(Item::where('eid','=',$eid)->get()); //TODO actually search
} }
public function showOneItem($event, $id) public function showOneItem($event, $id)

View file

@ -23,9 +23,6 @@ class Item extends Model
* *
* @var array * @var array
*/ */
protected $hidden = ['created_at','updated_at']; protected $hidden = ['created_at','updated_at', 'deleted_at', 'eid'];
public static function byEvent($event){
return DB::table('users')->join('events', 'users.eid', '=', 'events.eid')->get();
}
} }