/** * @param Guard $guard * @return \Dingo\Api\Http\Response */ public function index(Guard $guard) { $user = $guard->user()->id; $myOps = Op::whereUserId($user); $ops = $myOps->paginate(10); return $this->response->paginator($ops, new OpTransformer()); }
public function transform(Cycle $cycle) { $ou = Op::all()->where('id', $cycle->op_id); return ['name' => $cycle->name, 'description' => $cycle->description, 'start_date' => $cycle->start_date, 'end_date' => $cycle->end_date, 'medium' => $cycle->medium, 'op' => $ou->pluck('unit_name')]; }