vendredi 18 décembre 2015

Cache to Avoid Database calls in validator : Laravel 5.2

What I am doing ?

I am fetching the records from database in 2 ways.

Approach 1

Imposing the validation before saving the record

$v = \Validator::make($request->all(), [
    'Category' => 'required|unique:tblcategory|max:25|min:5'
]);

if ($v->fails()) {
    return \Redirect::back()
                ->withErrors($v)
                ->withInput();
}

Approach 2

Fetching the records from database

$Categories = \App\Models\Skill\Category_Model::all();


What's the question ?

In Approach 2, I could avoid database calls by implementing the cache with below code \Cache::put('Categories', $Categories, 60);

How can I avoid Database calls in case of Approach 1



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire