src/Post/Post.php
public function find($postId, $columns = ['*'])
    {
        $cache_key = (is_array($columns) && $columns[ 0 ] == '*') ? 'post_' . $postId : 'post_' . md5($postId . http_build_query($columns));

        // See if we've the post cached earlier in this request and return it if it's available
        if (Cache::tags(['posts', 'post_' . $postId])->has($cache_key)) {
            return Cache::tags(['posts', 'post_' . $postId])->get($cache_key);
        } else {
            // Eventually we try to fetch the post from the database or return an error
            try {
                $post = $this->postRepository->findOrFail($postId, $columns);
                // Cache it using the caching system
                Cache::tags(['posts', 'post_' . $postId])
                     ->put($cache_key, $post, \Option::get('posts_cache_expires', 60));

                return $post;
            } catch (\Exception $e) {
                return null;
            }
        }
    }
public function find($postId, $columns = ['*'])
    {
        $cache_key = (is_array($columns) && $columns[ 0 ] == '*') ? 'post_' . $postId : 'post_' . md5($postId . http_build_query($columns));

        // See if we've the post cached earlier in this request and return it if it's available
        if (Cache::tags(['posts', 'post_' . $postId])->has($cache_key)) {
            return Cache::tags(['posts', 'post_' . $postId])->get($cache_key);
        } else {
            // Eventually we try to fetch the post from the database or return an error
            try {
                $post = $this->postRepository->findOrFail($postId, $columns);
                // Cache it using the caching system
                Cache::tags(['posts', 'post_' . $postId])
                     ->put($cache_key, $post, \Option::get('posts_cache_expires', 60));

                return $post;
            } catch (\Exception $e) {
                return null;
            }
        }
    }
public function find ( $ postId , $ columns = [ '*' ] ) { $ cache_key = ( is_array ( $ columns ) && $ columns [ 0 ] == '*' ) ? 'post_' . $ postId : 'post_' . md5 ( $ postId . http_build_query ( $ columns ) ) ; // See if we've the post cached earlier in this request and return it if it's available if ( Cache :: tags ( [ 'posts' , 'post_' . $ postId ] ) -> has ( $ cache_key ) ) { return Cache :: tags ( [ 'posts' , 'post_' . $ postId ] ) -> get ( $ cache_key ) ; } else { // Eventually we try to fetch the post from the database or return an error try { $ post = $ this -> postRepository -> findOrFail ( $ postId , $ columns ) ; // Cache it using the caching system Cache :: tags ( [ 'posts' , 'post_' . $ postId ] ) -> put ( $ cache_key , $ post , \ Option :: get ( 'posts_cache_expires' , 60 ) ) ; return $ post ; } catch ( \ Exception $ e ) { return null ; } } }
Find a post object by id

@param integer $postId

@return \Illuminate\Support\Collection||null
Find a post object by id