PHP code example of chrisjk123 / laravel-blogger

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

    

chrisjk123 / laravel-blogger example snippets


// Alias namespace path:
// Chriscreates\Blog\Post
// Chriscreates\Blog\Category
// Chriscreates\Blog\Tag
// Chriscreates\Blog\Comment

// Search by the short whereCategories method OR use whereCategory() and specify the field
$results = Post::whereCategories($categories = null)->get();
$results = Post::whereCategory($field, $operator, $value)->get();

// Search by Category ID OR IDs
$results = Post::whereCategories(1)->get();
$results = Post::whereCategory('id', 1)->get();
----------
$results = Post::whereCategories([3, 6, 7])->get();
$results = Post::whereCategory('id', [3, 6, 7])->get();

// Search by Category name OR names
$results = Post::whereCategories('Izabella Bins II')->get();
$results = Post::whereCategory('name', 'Izabella Bins II')->get();
----------
$results = Post::whereCategories(['Izabella Bins II', 'Osborne Fay'])->get();
$results = Post::whereCategory('name', ['Izabella Bins II', 'Osborne Fay'])->get();

// Search by Category model or a Category Collection
$category = Category::where('id', 7)->first();
$results = Post::whereCategories($category)->get();
----------
$categories = Category::whereIn('id', [3, 6, 7])->get();
$results = Post::whereCategories($categories)->get();

// Search by related Post (tags or category)
$post = Post::find(8);
$results = Post::relatedByPostTags($post)->get();
----------
$results = Post::relatedByPostCategory($post)->get();

// Search by published Posts only
Post::published()->get();
----------
Post::publishedLastMonth()->get();
----------
Post::publishedLastWeek()->get();

// Search by unpublished Posts only
Post::notPublished()->get();

// Search by scheduled Posts only
Post::scheduled()->get();

// Search by drafted Posts only
Post::draft()->get();

// Order by latest published
Post::orderByLatest()->get();

/*
|--------------------------------------------------------------------------
| User relations
|--------------------------------------------------------------------------
|
| This is the default path to the User model in Laravel and primary key.
| You are free to change this path to anything you like.
|
*/

'user' => [
    'user_class' => \App\User::class,
    'user_key_name' => 'id',
],

/*
 |--------------------------------------------------------------------------
 | Post commenting options
 |--------------------------------------------------------------------------
 |
 | The default for commenting on posts is enabled, as well as guest
 | commenting. Feel free to change these conditions to false.
 |
 */

'posts' => [
    'allow_comments' => true,
    'allow_guest_comments' => true,
],
bash
php artisan blog:install
html
{{-- Within the head of your app.blade.php file --}}
{!! SEOMeta::generate() !!}
{!! OpenGraph::generate() !!}
html
{{-- Print the published post markdown content --}}
{!! $post->parsed_markdown !!}
bash
php artisan blog:setup --data