Created
March 16, 2016 23:41
-
-
Save edyonil/c1b6521dcccb11c0f989 to your computer and use it in GitHub Desktop.
local_scope_repositorio.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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