/**
  * Send Contact Email.
  *
  * @return Response
  */
 public function contact()
 {
     // Get the contact info from DB
     $user = $this->contactRepository->getFirst();
     // Validate the input data
     $val = $this->contactRepository->getContactForm();
     if (!$val->isValid()) {
         return Redirect::back()->withInput()->with('errors', $val->getErrors());
     }
     $input = array_merge(Input::only(['sender_name', 'sender_email', 'body']), $user->toArray());
     Event::fire('contact.contact', [$input]);
     return Redirect::home()->with('success', trans('word.mail_sent'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $val = $this->contactRepository->getCreateForm();
     if (!$val->isValid()) {
         return Redirect::back()->with('errors', $val->getErrors())->withInput();
     }
     $contact = $this->contactRepository->getFirst();
     if ($contact) {
         if (!$this->contactRepository->update($contact->id, $val->getInputData())) {
             return Redirect::back()->with('errors', $this->contactRepository->errors())->withInput();
         }
     } else {
         if (!$this->contactRepository->create($val->getInputData())) {
             return Redirect::back()->with('errors', $this->contactRepository->errors())->withInput();
         }
     }
     return Redirect::action('AdminContactsController@index')->with('success', 'Saved');
 }
Example #3
0
<?php

define('THEME', 'theme1');
define('ROOT', getcwd());
chdir('admin');
require_once 'admin/init.php';
require_once 'lib/route/Route.php';
new TSession();
TTransaction::open('blog');
// render a category
Route::get('show_category', function ($args) {
    $partial_article = file_get_contents(ROOT . '/templates/' . THEME . '/partials/article.html');
    $partial_category = file_get_contents(ROOT . '/templates/' . THEME . '/partials/category.html');
    $category_id = (int) $args['category_id'];
    $category = isset($args['category_id']) ? $args['category_id'] : Category::getFirst();
    $categories = CategoryRender::render($category_id, $partial_category);
    $articles = PostRender::renderForCategory($category_id, $partial_article);
    $category = new Category($category_id);
    render_content(['articles' => $articles, 'category' => $categories]);
});
// render a post
Route::get('show_post', function ($args) {
    $partial_article = file_get_contents(ROOT . '/templates/' . THEME . '/partials/article.html');
    $partial_category = file_get_contents(ROOT . '/templates/' . THEME . '/partials/category.html');
    $post_id = isset($args['post_id']) ? (int) $args['post_id'] : NULL;
    $post = new Post($post_id);
    $articles = PostRender::renderPost(new Post($post_id), $partial_article);
    $categories = CategoryRender::render($post->category_id, $partial_category);
    render_content(['articles' => $articles, 'category' => $categories]);
});
// default action