🎃
$this->middleware('can:manage')как сюда аргумент передать ?
Size: a a a
🎃
$this->middleware('can:manage')как сюда аргумент передать ?
B
B
🎃
С
AH
$xml = (new CentersRepository())->getByTM($request->_tm);
$searchContacts = (new CentersSearch($xml));
$result = $searchContacts->regionsWithCities();
return Response::success($result);
class Searcher
{
protected $repository;
protected $tm_id;
public function __construct(CentersRepository $repository)
{
$this->repository = $repository;
}
public function tm(int $id): self
{
$this->tm_id = $id;
return $this;
}
public function regionsWithCities()
{
return $this->searcher()->regionsWithCities();
}
protected function searcher()
{
return new CentersSearch($this->repository());
}
protected function repository()
{
return $this->repository->getByTM($this->tm_id);
}
}
class MyController extends Controller
{
public function search(Request $request, Searcher $searcher)
{
$searcher->tm($request->get('id'));
$result = $searcher->regionsWithCities();
return Response::success($request);
}
}
AH
$this->middleware('can:manage')как сюда аргумент передать ?
$this->middleware('can:manage,foo,bar')В мидлваре:
__construct(string $type, $val1, $val2)
// $type == 'manage'
// $val1 == 'foo'
// $val2 == 'bar'
С
class Searcher
{
protected $repository;
protected $tm_id;
public function __construct(CentersRepository $repository)
{
$this->repository = $repository;
}
public function tm(int $id): self
{
$this->tm_id = $id;
return $this;
}
public function regionsWithCities()
{
return $this->searcher()->regionsWithCities();
}
protected function searcher()
{
return new CentersSearch($this->repository());
}
protected function repository()
{
return $this->repository->getByTM($this->tm_id);
}
}
class MyController extends Controller
{
public function search(Request $request, Searcher $searcher)
{
$searcher->tm($request->get('id'));
$result = $searcher->regionsWithCities();
return Response::success($request);
}
}
AH
B
$this->middleware('can:manage,foo,bar')В мидлваре:
__construct(string $type, $val1, $val2)
// $type == 'manage'
// $val1 == 'foo'
// $val2 == 'bar'
Gate::define('manage', function (User $user) {сюда нужно передать юзера через дерективу can внутри конструктора
return $user;
});
AH
Gate::define('manage', function (User $user) {сюда нужно передать юзера через дерективу can внутри конструктора
return $user;
});
RK
AH
RK
RK
С
class Searcher
{
protected $repository;
protected $tm_id;
public function __construct(CentersRepository $repository)
{
$this->repository = $repository;
}
public function tm(int $id): self
{
$this->tm_id = $id;
return $this;
}
public function regionsWithCities()
{
return $this->searcher()->regionsWithCities();
}
protected function searcher()
{
return new CentersSearch($this->repository());
}
protected function repository()
{
return $this->repository->getByTM($this->tm_id);
}
}
class MyController extends Controller
{
public function search(Request $request, Searcher $searcher)
{
$searcher->tm($request->get('id'));
$result = $searcher->regionsWithCities();
return Response::success($request);
}
}
С