Answers for "use switch laravel"

PHP
1

switch in laravel

@switch($i)
    @case(1)
        First case...
        @break

    @case(2)
        Second case...
        @break

    @default
        Default case...
@endswitch
Posted by: Guest on October-27-2020
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