I've creating a dynamic form which let user can add or delete the form elements so the amount of rows is depend on those form elements.However when all rows or data were inserted into database then I will return all those Ids (Not only the last ID ) back.
Examples:
public function insertUser(){
$id [];
DB::beginTransaction();
for($i=1;$i<count(Request::input('users'));$i++){
$Models = new Models_user();
$Models->name = Request::input('name');
$Models->Fname = Request::input('Fname');
$Models->save();
$id[] = $Models->id;
}
DB::commit();
return $id;
}
As above examples It will do multiples insert depend on count(Request::input('users')) amount and then return all those ids.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2iGZBRS
via IFTTT
Aucun commentaire:
Enregistrer un commentaire