PHP code example of tarkhov / eloquent-cache

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

    

tarkhov / eloquent-cache example snippets



namespace App;

use EloquentCache\Database\Eloquent\CacheModel;

class Post extends CacheModel
{
    protected $fillable = [
        'category_id',
        'title',
        'description',
    ];

    public function category()
    {
        return $this->belongsTo('App\Category', 'category_id');
    }
}


namespace App;

use EloquentCache\Database\Eloquent\CacheModel;

class Category extends CacheModel
{
    protected $cacheTags = ['category'];
    protected $fillable = [
        'title',
        'description',
    ];
}