Each technician have just one 'Tarification' for a specific 'tache' i made a condition if the 'tarification' exists it return an error message but in another page I would display it in the same on a popup
public function store(Request $request)
{
$count = tarificationtache::where('technicien_id', $request-
>input('technicien_id'))
->where('tache_id', $request->input('tache_id'))
->count();
if ($count > 0) {
// TODO: adjust response according to your need
return response()->json(['error' => "Ce technicien a cette
tarification"], 400);
} else {
$tarification = new tarificationtache;
$tarification->tache_id = $request->input('tache_id');
$tarification->Tarif = $request->input('Tarif');
$tarification->technicien_id = $request->input('technicien_id');
$tarification->save();
// TODO: adjust response according to your need
return redirect('technicien');
}
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2N71vOm
via IFTTT
Aucun commentaire:
Enregistrer un commentaire