PHP code example of ethicks / filtcms

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

    

ethicks / filtcms example snippets


use EthickS\FiltCMS\FiltCMSPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        // ...
        ->plugins([
            FiltCMSPlugin::make(),
        ]);
}

use EthickS\FiltCMS\Facades\FiltCMS;

// Get a page
$page = FiltCMS::page('about-us');

if ($page->exists()) {
    echo $page->getTitle();
    echo $page->getBody();
    echo $page->getExcerpt();
    echo $page->getFeaturedImage();
    echo $page->getViewsCount();
    echo $page->getLikesCount();
    echo $page->getCommentsCount();
}

// Get a blog post
$blog = FiltCMS::blog('my-post-slug');

if ($blog->exists()) {
    echo $blog->getTitle();
    echo $blog->getBody();
    print_r($blog->getTags());
    echo $blog->getCategory()->name;
    echo $blog->getAuthor()->name;
}

@php
    $filtCms = app(\EthickS\FiltCMS\FiltCMS::class)->page('about-us');
@endphp

@if($filtCms->exists())
    <h1>{{ $filtCms->getTitle() }}</h1>
    <div>{!! $filtCms->getBody() !!}</div>
@endif

use EthickS\FiltCMS\Models\Blog;
use EthickS\FiltCMS\Models\Page;

protected function schedule(Schedule $schedule)
{
    $schedule->call(function () {
        Blog::where('status', 'scheduled')
            ->where('published_at', '<=', now())
            ->update(['status' => 'published']);
            
        Page::where('status', 'scheduled')
            ->where('published_at', '<=', now())
            ->update(['status' => 'published']);
    })->everyMinute();
}
bash
php artisan filtcms:install && npm install && npm run build
bash
php artisan vendor:publish --tag="filtcms-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="filtcms-config"
bash
php artisan vendor:publish --tag="filtcms-views"