Looking to hire Laravel developers? Try LaraJobs

laravel-model-cache maintained by alaraiabdiallah

Description
Laravel model cache
Author
Last update
2018/08/29 23:57 (dev-master)
License
Links
Downloads
66

Comments
comments powered by Disqus

Laravel Model Cache

This package is simple way to cache model query to collection.

Installation

composer require "alaraiabdiallah/laravel-model-cache":"dev-master"

Example

You required to make scope Cache Query for register query to cache. This example it will select all data from user model then cache it

<?php

namespace App;

use ModelCache\Contract as CacheContract;
use ModelCache\Cacheable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements CacheContract
{
    use Notifiable,Cacheable;

    protected $fillable = [
        'name', 'email', 'password',
    ];

    protected $hidden = [
        'password', 'remember_token',
    ];

    public function scopeCacheQuery($query)
    {
        return $query->get();
    }
}