Answer the question
In order to leave comments, you need to log in
How to perform an admin-only function?
I have a function to add a product
public function Add(Request $request){
$eqmodel = new Eqmodel;
$htmlmodel = new Eqhtml;
$htmlmodel->html = $request->eq_html;
$eqmodel->name = $request->eq_name;
$eqmodel->price = str_replace(" ","", $request->eq_price);
$eqmodel->sale = str_replace(" ","", $request->eq_sale);
$eqmodel->url = $request->eq_url;
$eqmodel->image = $request->eq_image;
$eqmodel->type_id = intval($request->eq_category);
$eqmodel->descrip = $request->eq_descript;
$eqmodel->video = $request->eq_video;
$eqmodel->rgx = $request->eq_rgx;
$eqmodel->save();
if ($eqmodel->save()) {
$htmlmodel->eq_id = $eqmodel->id;
if($htmlmodel->save()){
return response()->json(array('success' => true), 200);
}
}
}
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