closet; } public function add(Request $request, $uid) { /** @var Texture */ $texture = Texture::findOrFail($request->input('tid')); /** @var User */ $user = User::findOrFail($uid); $user->closet()->attach($texture->tid, ['item_name' => $texture->name]); return json('', 0, compact('user', 'texture')); } public function remove(Request $request, $uid) { /** @var Texture */ $texture = Texture::findOrFail($request->input('tid')); /** @var User */ $user = User::findOrFail($uid); $user->closet()->detach($texture->tid); return json('', 0, compact('user', 'texture')); } }