Made it so you get send to index after you make,edit and update user information

This commit is contained in:
Neerholt 2020-07-01 09:50:37 +02:00
parent 2b69938251
commit eb48514545
1 changed files with 17 additions and 4 deletions

View File

@ -5,6 +5,7 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use App\Contact; use App\Contact;
use phpDocumentor\Reflection\Types\Context;
class ContactController extends Controller class ContactController extends Controller
{ {
@ -59,9 +60,15 @@ class ContactController extends Controller
]); ]);
$contact = new Contact($requestContact); $contact = new Contact($requestContact);
$contact->save(); $saved = $contact->save();
if(!$saved){
return Response::detect("contacts.store");
}else{
$contact = Contact::query()->paginate($request->input("limit", 20));
return Response::detect("contacts.index", ['contacts' => $contact]);
}
return Response::detect("contacts.store");
} }
/** /**
@ -101,9 +108,15 @@ class ContactController extends Controller
$data = $request->all(); $data = $request->all();
$contact = Contact::find($id); $contact = Contact::find($id);
$contact->update($data); $contact->update($data);
$contact->save(); $saved = $contact->save();
if(!$saved){
return Response::detect("contacts.update", [ "contacts" => $contact ]);
}else{
$contact = Contact::query()->paginate($request->input("limit", 20));
return Response::detect("contacts.index", ['contacts' => $contact]);
}
return Response::detect("contacts.update", [ "contacts" => $contact ]);
} }
/** /**