Answer the question
In order to leave comments, you need to log in
What is the best way to check if the content is relevant to the selected user?
I have a table of pre-orders that includes fields like this
$table->increments('id');
$table->char('group_cd', 16);
$table->char('group_sub_cd', 2);
...
$table->integer('customer_id')->unsigned()->index();
public function create()
{
$customer = new Customer;
return view('folder1.customer', compact('customer'));
}
public function createWithPreorder($preorderId)
{
$this->checkPreorderGroup($preorderId);
$customer = new Customer;
return view('customer.customer', compact('customer'));
}
private function checkPreorderGroup($preorderId)
{
$preorder = EstimateInfo::where('id', $preorderId)->group()->get();
if ($preorder->isEmpty()) {
return abort(404);
}
return;
}
public function scopeGroup($query)
{
$authUser= Auth::user();
return $query->where('group_cd', $authUser->group_cd)->where('group_sub_cd', $authUser->group_sub_cd);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question