/** * @param int $id * @param $encontristaId * @return mixed */ function unsubscribe($id, $encontristaId = null) { /** @var Encontrista $encontrista */ $encontrista = Encontrista::find(is_null($encontristaId) ? Auth::user()->id : $encontristaId); if (is_null($response['encontrista'] = !is_null($encontrista) ? $encontrista->id : null)) { return response()->json($response); } if (is_null($response['course_subscribed'] = !is_null(Meeting::find($id)) ? Meeting::find($id)->id : null)) { return response()->json($response); } $response['old_subscribe_status'] = !is_null($encontrista->meetings()->find($id)); if ($response['modified_subscribe_status'] = $response['old_subscribe_status']) { $encontrista->meetings()->detach($response['course_subscribed']); } $response['new_subscribe_status'] = !is_null($encontrista->meetings()->find($id)); return response()->json($response); }
/** * Run the database seeds. * * @return void */ public function run() { Encontrista::create(['name' => 'rede_encontrista', 'email' => '*****@*****.**', 'nickname' => 'admin', 'password' => bcrypt('qwe1234R')]); }