PHP code example of kinjari / laravel-zenblog

1. Go to this page and download the library: Download kinjari/laravel-zenblog 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/ */

    

kinjari / laravel-zenblog example snippets


return [
    'api_url' => env('ZENBLOG_API_URL', 'https://demo.zenblog.org/api'),
    'blog_id' => env('ZENBLOG_BLOG_ID', null),
];

use Kinjari\LaravelZenblog\Models\Post;

// Get all posts
$posts = Post::all();

// Find a specific post by slug
$post = Post::find('my-blog-post');

// Get paginated posts
$paginatedPosts = Post::paginate(10, 1); // 10 per page, page 1

use Kinjari\LaravelZenblog\Models\Category;

// Get all categories
$categories = Category::all();

// Get paginated categories
$paginatedCategories = Category::paginate(10, 1);

use Kinjari\LaravelZenblog\Models\Tag;

// Get all tags
$tags = Tag::all();

// Get paginated tags
$paginatedTags = Tag::paginate(10, 1);

use Kinjari\LaravelZenblog\Models\Author;

// Get all authors
$authors = Author::all();

// Find a specific author by slug
$author = Author::find('john-doe');

// Get paginated authors
$paginatedAuthors = Author::paginate(10, 1);

$post = Post::find('my-blog-post');
echo $post->title;
echo $post->content;
echo $post->slug;

$posts = Post::all();
foreach ($posts as $post) {
    echo $post->title;
}
bash
php artisan vendor:publish --tag="laravel-zenblog-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="laravel-zenblog-config"
bash
php artisan vendor:publish --tag="laravel-zenblog-views"