public function browse($slug) { try { $board = Board::bySlug($slug)->toArray(); } catch (AccessDeniedException $e) { return Theme::view('errors/access_denied'); } catch (ModelNotFoundException $e) { return Theme::view('errors/not_found'); } return Theme::view('index', ['current_board' => $board]); }
public function read(Application $app, $id, $slug) { try { $post = Post::with('author', 'children', 'children.author')->findOrFail($id); } catch (ModelNotFoundException $e) { return Theme::view('errors/not_found'); } if ($slug != $post->slug) { return $app->redirect($app->path('site.post.read', ['id' => $id, 'slug' => $post->slug])); } if (!$post->board->userHasAccess()) { return Theme::view('errors/access_denied'); } return Theme::view('post', ['post' => $post->toArray()]); }
public function register(Request $request, Application $app) { if (Auth::user()) { return $app->redirect($app->path('site.index')); } $vars = array(); $form = Form::create('registration_form')->add('name', Type\TextType::class)->add('username', Type\TextType::class, ['constraints' => [new Assert\Regex(['pattern' => '/^[A-Za-z0-9_]+$/', 'match' => true, 'message' => 'Username must only contain alphanumeric characters and underscores.']), new CustomAssert\UniqueRecord(['model' => User::class, 'row' => 'username', 'message' => 'Username already in use.'])]])->add('email', Type\TextType::class, ['constraints' => [new Assert\Email(), new CustomAssert\UniqueRecord(['model' => User::class, 'row' => 'email', 'message' => 'Email already in use.'])]])->add('password', Type\RepeatedType::class, ['type' => Type\PasswordType::class, 'first_options' => ['label' => 'Password'], 'second_options' => ['label' => 'Repeat Password'], 'invalid_message' => 'Password fields did not match.', 'constraints' => [new Assert\Length(['min' => 8, 'minMessage' => 'Password must be at least 8 characters.'])]]); $form = $form->getForm(); $form->handleRequest($request); if ($form->isValid()) { $data = $form->getData(); $user = User::create($data); Auth::login($user); return $app->redirect($app->path('site.index')); } $vars['registration_form'] = $form->createView(); return Theme::view('auth/register', $vars); }
/** * Wrapper for Theme::addToFoot() * Add code before </body> of template * * @param string $code Code */ public function addToFoot($code) { return Theme::addToFoot($code); }
public function index() { return Theme::view('index'); }