Exemple #1
0
 public function create()
 {
     // Load Doctrine library
     $this->load->library('doctrine');
     // Create new post
     $post = new Post();
     $post->title('Example post');
     $post->content('<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>');
     $post->visits(0);
     // Save post in db
     $this->doctrine->em->persist($post);
     $this->doctrine->em->flush();
     echo 'Post created';
 }
Exemple #2
0
 public function index(Events\Event $event)
 {
     $page = $event->get('page');
     $page = empty($page) ? 1 : $page;
     $posts = Models\Post::find(array('search' => 'all', 'values' => 'all', 'page' => $page, 'fields' => 'summary'));
     $event->set('posts', $posts);
 }
 public function action_remove($id)
 {
     $post = \Blog\Models\Post::find($id);
     if ($post) {
         $post->delete();
     }
     return Redirect::to_action('blog::admin.post@list');
 }
 public function action_resolve($post_id)
 {
     if ($post = Post::where_id($post_id)->first(array('id', 'slug'))) {
         return Redirect::to_action('blog::home@show', array($post->id, $post->slug));
     } else {
         return Event::first('404');
     }
 }
Exemple #5
0
 private function findPost($id)
 {
     return Models\Post::find(array('search' => 'id', 'values' => $id));
 }
<?php

Route::get('/', function () {
    $posts = \Blog\Models\Post::order_by('created_at', 'desc')->take(5)->get();
    return View::make('home.index')->with("posts", $posts);
});
Route::get('telecharger, download', array('as' => 'telecharger', function () {
    return Redirect::to('http://laravel.com/download');
}));
Route::get('irc', array('as' => 'irc', function () {
    return view::make('irc.index');
}));
Route::controller(array('contact'));
Event::listen('404', function () {
    return Response::error('404');
});
Event::listen('500', function () {
    return Response::error('500');
});
Route::filter('before', function () {
    // Do stuff before every request to your application...
});
Route::filter('after', function ($response) {
    // Do stuff after every request to your application...
});
Route::filter('csrf', function () {
    if (Request::forged()) {
        return Response::error('500');
    }
});
Route::filter('auth', function () {
 public function action_index()
 {
     $cntBlogPost = \Blog\Models\Post::count();
     return View::make('blog::admin.index')->with('nbPost', $cntBlogPost);
 }