andersao / andersao/l5-repository

update with criteria

Đang mở
#667 0 bình luận 2 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
PHP
Star
4.2k
Fork
880
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Hi
I was wondering how I can update a record with criteria
I have a users table and info table with one to one relationship
Users need to be able to update only their info which is connected through user_id on the info table
what is the best solution?

$this->repository->pushCriteria(EndUserCriteria::class);
$client = $this->repository->update($request->all(), $id);

class EndUserCriteria implements CriteriaInterface
{
/**
* Apply criteria in query repository
*
* @param string $model
* @param RepositoryInterface $repository
*
* @return mixed
*/
public function apply($model, RepositoryInterface $repository)
{
$model = $model->where('user_id','=', Auth::user()->id );
return $model;
}
}

this doesn't work

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.