PHP code example of contentpulseio / laravel

1. Go to this page and download the library: Download contentpulseio/laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

contentpulseio / laravel example snippets


use ContentPulse\Laravel\Models\Content;

Content::published()->get();          // status = published, newest first
Content::whereCategory('laravel')->get();
Content::whereTag('seo')->get();

use App\Models\Post;
use ContentPulse\Laravel\Models\Content;

public function index()
{
    $feed = Post::published()->get()
        ->concat(Content::published()->get())
        ->sortByDesc('published_at')
        ->values();

    return view('blog.index', ['posts' => $feed]);
}

public function show(string $slug)
{
    $post = Post::published()->where('slug', $slug)->first()
        ?? Content::published()->where('slug', $slug)->firstOrFail();

    return view('blog.show', ['post' => $post]);
}

$content = Content::published()->where('slug', $slug)->firstOrFail();

echo $content->rendered_html;
bash
composer contentpulse:install
php artisan migrate
bash
php artisan contentpulse:repair-images --dry-run
php artisan contentpulse:repair-images
php artisan contentpulse:repair-images --external-id=01KXXXXXXXXXXXXXXXXXXXXXXX
bash
php artisan vendor:publish --tag=contentpulse-views
bash
php artisan contentpulse:sync --locale=en