Files
newznab-tmux/app/Support/Database/Builder.php
T
DariusIII ce193c994b Apply fixes from StyleCI
[ci skip] [skip ci]
2018-05-10 09:35:39 +00:00

36 lines
832 B
PHP

<?php
namespace App\Support\Database;
use Illuminate\Support\Facades\Cache;
use Illuminate\Database\Query\Builder as QueryBuilder;
class Builder extends QueryBuilder
{
/**
* Taken from https://laracasts.com/discuss/channels/guides/never-execute-a-duplicate-query-again.
*
* Run the query as a "select" statement against the connection.
*
* @return array
*/
protected function runSelect()
{
return Cache::store('request')->remember($this->getCacheKey(), 1, function () {
return parent::runSelect();
});
}
/**
* Returns a Unique String that can identify this Query.
*
* @return string
*/
protected function getCacheKey()
{
return json_encode([
$this->toSql() => $this->getBindings(),
]);
}
}