PHP code example of cklmercer / laravel-model-stash

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

    

cklmercer / laravel-model-stash example snippets


// Role.php

use Cklmercer\ModelStash\CacheForever;
use Illuminate\Database\Eloquent\Model;

class Role extends Models 
{
    use CacheForever;
     
    // truncated for brevity..
}

$roles = \Cache::get('roles')

// Role.php

use Cklmercer\ModelStash\CacheForever;
use Illuminate\Database\Eloquent\Model;

class Role extends Model
{
    use CacheForever;

    /**
     * The model's cache name.
     *
     * @var string
     */
    protected $cacheName = 'cachedRoles';

    // truncated for brevity..
}

$roles = \Cache::get('cachedRoles');

$role = \Cache::get('roles:1')

// Role.php

use Cklmercer\LaravelModelStash\CacheForever;
use Illuminate\Database\Eloquent\Model;

class Role extends Model
{
    use CacheForever;

    /**
     * The model's cache key.
     *
     * @var string
     */
     protected $cacheKey = 'slug';

     // truncated for brevity..
}

$role = \Cache::get('roles:admin')