Answers for "switch case in php laravel"

PHP
0

switch case in laravel controller

you can use $request->get('submitbutton') in your method :

for example :
public function setGroupApprovel(Request $request)
{
    switch ($request->get('submitbutton')) {
        case 'save':
            $groups_create_subscription = new GroupSubscription();
            $groups_create_subscription->idgroups = $request->input('idgroup');
            $groups_create_subscription->subscriber = $request->input('iduser');
            $groups_create_subscription->save();
            break;
        case 'nosave':

            $groups_request = new GroupRequest();
            $groups_request->iduser::find($request->iduser);
            $groups_request->request_active = 0;
            $groups_request->save;
            break;
    }
}

and i use :
<input id='submit' class="btn btn-default" type='submit' name = 'submitbutton' value = 'save'>
<input id='submit' class="btn btn-default" type='submit' name = 'submitbutton' value = 'nosave'>

instead of :
{!! Form::submit('Yes',['class' => 'btn btn-default', 'name' => 'submitbutton', 'value' => 'save'])!!}
{!! Form::submit('No',['class' => 'btn btn-default', 'name' => 'submitbutton', 'value' => 'nosave'])!!}
Posted by: Guest on June-12-2021

Browse Popular Code Answers by Language