コード例 #1
0
ファイル: posts.php プロジェクト: jgat2012/hp_oms
 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';
 }
コード例 #2
0
ファイル: Index.php プロジェクト: eksith/Blog
 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);
 }
コード例 #3
0
 public function action_remove($id)
 {
     $post = \Blog\Models\Post::find($id);
     if ($post) {
         $post->delete();
     }
     return Redirect::to_action('blog::admin.post@list');
 }
コード例 #4
0
 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');
     }
 }
コード例 #5
0
ファイル: Edit.php プロジェクト: eksith/Blog
 private function findPost($id)
 {
     return Models\Post::find(array('search' => 'id', 'values' => $id));
 }
コード例 #6
0
<?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 () {
コード例 #7
0
 public function action_index()
 {
     $cntBlogPost = \Blog\Models\Post::count();
     return View::make('blog::admin.index')->with('nbPost', $cntBlogPost);
 }