/** * Edit specific user * * @param integer $id * @return View */ public function edit($id) { // Get user and prepare the form $user = $this->user->find($id); $form = new UserForm($user, array('route' => array('system.users.update', $id))); return View::make('krustr::users.edit')->withUser($user)->withForm($form); }
/** * GET /account(/:name). * * @param null|string $name */ public function viewAccountAction($name = null) { $redis = $this->app->container->get('redis.client'); $userRepository = new UserRepository($redis); $user = $userRepository->find($name); $jsonPath = $this->app->config('json_path') . 'users/github/' . $name . '.json'; $this->app->notFoundIf(file_exists($jsonPath) === false)->redirectUnless($name, '/profile')->render('account.html', ['account' => $user]); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $user = $this->userRepository->find($id); if (!$user) { return $this->toJSONResponse(['error' => ['status' => 400, 'message' => 'Invalid user id: ' . $id]], 400); } $user->remove(); return $this->toJSONResponse([]); }
/** * Display a listing of the resource. * * @param Encrypter $encrypter * @param $hash * @return Response * @throws Exception */ public function index(Encrypter $encrypter, $hash) { try { $params = $encrypter->decrypt($hash); $project = $this->projectRepository->find($params['project']); $user = $project->users->find($params['user']); if (is_null($user)) { throw new Exception('the user was not found'); } $sourceClass = app()->make('Knoters\\Services\\Sources\\' . ucfirst($project->type->name) . 'Service'); $video = $sourceClass->getVideo($project->video_id); $this->fractal->setSerializer(new ArraySerializer()); JavaScriptFacade::put(['user' => $this->fractal->createData(new Item($user, new UserTransformer()))->toArray(), 'project' => $this->fractal->createData(new Item($project, new ProjectTransformer()))->toArray()]); return view('editor', ['video' => $video, 'project' => $project]); } catch (Exception $e) { throw $e; $this->errorResponse($e); } }
/** * Methode zum anzeigen des Contents. * * @return String Content der Applikation. */ public function display() { $user = UserRepository::find($this->request['id']); if ($user !== null) { $res = $user->toArray(); $res['status'] = 'success'; } else { $res = array('status' => 'error'); } $this->view->setTemplate($this->template); $this->view->assign('outlet', json_encode($res)); return $this->view->loadTemplate(); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $user = $this->user->find($id); return $user; }
/** * Bind data to the view. * * @param View $view * @return void */ public function compose(View $view) { $view->with('contact', $this->users->find($view->getData()['user']['id'])); }
/** @test **/ function it_finds_the_model_with_the_given_id_and_the_selected_fields() { $user = factory(User::class)->times(10)->create()->last(); // Fetch the last created user. $repository = new UserRepository($this->newContainerMock(new User())); $actual = $repository->find($user->id, ['email']); $this->assertEquals(['email'], array_keys($actual->toArray())); }
/** * The `User` instance for the currently-logged-in user, if present * * @protected * @return null|\User */ protected function user() { if (!$this->authenticated()) { return null; } return $this->userRepository->find($this->session->get('user_id')); }