Skip to content

Instantly share code, notes, and snippets.

@edyonil
Created March 16, 2016 23:41
Show Gist options
  • Save edyonil/c1b6521dcccb11c0f989 to your computer and use it in GitHub Desktop.
Save edyonil/c1b6521dcccb11c0f989 to your computer and use it in GitHub Desktop.
local_scope_repositorio.php
<?php
use Illuminate\Database\Eloquent\Model;
class Telefone extends Model {
public function scopeFilter($query)
{
$value = session('key');
return $query->where('ddd', $value);
}
}
class RepositorioTelefone
{
protected $model;
public function __construct(Telefone $telefone)
{
$this->model = $telefone;
}
public function all()
{
return $this->model->filter()->all();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment