Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Gabonator's avatar

Show flash message according to request

Hi,

I'm trying to display a flash message according by the request name.

This working only for the first and second variants, ('record')== 1 and ('registration')== 1.

Variant third and fourth ('record')== 0) not working

 if($request->input('record')== 1) {
            flash()->success( trans('web.events_record_wants_send'));
        }elseif($request->input('registration')== 1){
            flash()->success( trans('web.events_rezervation_already'));
        }elseif($request->input('record')== 0){
            flash()->success( trans('web.events_record_wants_unsend'));
        }else{
            flash()->success( trans('web.events_rezervation_unset'));
        }

Thx for help. gabriel

0 likes
2 replies
Snapey's avatar

Check your logic

        record    registration      
             1         X          web.events_record_wants_send
             0         1          web.events_rezervation_already

no valid combination for this
             0         X          web.events_record_wants_unsend
             ?         ?          web.events_rezervation_unset

Work out the truth table and write the correct logic, testing both flags at the same time

eg `if( $request->input('record')==0 && $request->input('registration')==1)

Ideally improve your design so that this ugly mess is not needed

Gabonator's avatar

Sorry, but I do not understand what you want to say to me.

Please or to participate in this conversation.