I am saving data to a table with following store method.
public function store(Request $request)
{
foreach ($request->admin_id as $key=>$val){
$adminbillings = AdminBilling::create([
'month' => $request->month,
'rate' => $request->rate[$key],
'admin_id' => $val,
]);
}
return redirect('/');
}
Now, I want to check if any of the input values is already existed in the table before storing them. If a row in the table already contains all 3 same inputs, it should do nothing, otherwise store the inputs. It would be something like
if
$requested->month does not exist in month column ||
$requested->rate does not exist in rate column ||
$requested->admin_id does not exist in admin_id column
then
save
Please help me. I am using Laravel 5.4.
Thank you