public function mendaftar($id) { $penawaran = Penawaran::findOrFail($id); $user = Pegawai::findOrFail(\Input::get('user_id')); $id_pegawai_terdaftar = $penawaran->pegawai()->getRelatedIds(); if (in_array($user->id, $id_pegawai_terdaftar)) { return "already registered"; } $penawaran->pegawai()->attach($user->id); return $penawaran->pegawai; }
public function optionsValue() { $query = \Input::get('query'); $items = Pegawai::where('name', 'like', '%' . $query . '%')->take(10)->get(); return $items; }