PHP code example of bryceandy / press

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

    

bryceandy / press example snippets




namespace App\Fields;

use Bryceandy\Press\Contracts\FieldContract;
use Carbon\Carbon;

class Birthday extends FieldContract
{
    public static function process($field, $value, $data)
    {
        return [
            $field => Carbon::parse($value),
            // or $field => $value,
        ];
    }
}


/*
 * Package Service Providers...
 */
 App\Providers\PressServiceProvider::class,

/**
 * Aliases
 */
 'aliases' => [
    ...
    'Press' => Bryceandy\Press\Facades\Press::class,
 ],

private function registerFields()
{
    return [
        \App\Fields\Birthday::class,
    ];
}

$post = Bryceandy\Press\Post::all()->first();

// The field that was parsed with the Birthday class
$birthday = $post->extra('birthday');  

// The field that was only written in the markdown file without a custom class to parse
$field = $post->extra('field');   

// Other fields  
$title = $post->title;
$body = $post->body;  
bash
php artisan vendor:publish --tag=press-config
bash
php artisan migrate
bash
php artisan vendor:publish --tag=press-provider
bash
php artisan press:process