PHP code example of rogervila / laravel-autocache

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

    

rogervila / laravel-autocache example snippets


Post::with('categories')->get();

$post = Post::find($id);
$post->update(['title' => 'Your edited title']);

return Post::with('categories')->get();

Post::disableAutoCache();

// Do your database changes here

Post::enableAutoCache();


LaravelAutoCache\AutocacheServiceProvider::class,

/**
 * List of models that implement autocache by default.
 * Models have to also implement the Autocache trait
 * in order to work properly
 */
'models' => [
    App\Product::class,
],

namespace App;

use Illuminate\Database\Eloquent\Model;
use LaravelAutoCache\Autocache;

class Product extends Model
{
    use Autocache;
    ...
sh
php artisan vendor:publish --provider=" LaravelAutoCache\AutocacheServiceProvider"