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

BikashKatwal's avatar

required_if validator not working in prod

In Hall model,

public static $rules = array(
        'name' => 'required',
        'capacity' => 'required|numeric',
        'street_number' => 'required',
        'route' => 'required',
        'locality' => 'required',
        'state' => 'required',
        'postcode' => 'required',
        'email' => 'email',
        'appointedd_appid' => 'required_if:isbooking_enabled,1',
    );

    public static function messages()
    {
        return [
            'appointedd_appid.required_if' => 'The appointedd appid field is required when enable booking is checked.'
        ];
    }

I have added inside $rules as shown above and use it in the controller

$validation = Validator::make(Input::all(), Hall::$rules, Hall::messages());

   'appointedd_appid' => 'required_if:isbooking_enabled,1',
public static function messages()
    {
        return [
            'appointedd_appid.required_if' => 'The appointedd appid field is required when enable booking is checked.'
        ];
    }

but when I deploy it to prod, it is interrupting the whole project. It seems like the whole server is down. but when I remove these code everything works. What is causing these issue only in prod? I have these project in laravel 4.2. Is there any other way to use required_if apart from the defined above and using custom message in validation.php.

0 likes
7 replies
tisuchi's avatar

@bikashkatwal

Where is your isbooking_enabled rules?

Isn't that suppose to be like this?

public static $rules = array(
    'name' => 'required',
    'capacity' => 'required|numeric',
    'street_number' => 'required',
    'route' => 'required',
    'locality' => 'required',
    'state' => 'required',
    'postcode' => 'required',
    'email' => 'email',
    'isbooking_enabled' => 1,
    'appointedd_appid' => 'required_if:isbooking_enabled,1',
);
BikashKatwal's avatar

@tisuchi it gives error when I add

'isbooking_enabled' => 1,

but removing this works fine and the problem is only in prod.

tisuchi's avatar

@bikashkatwal

I am sorry. It suppose to be -

'isbooking_enabled' => 'required',

What I mean, if you want to use required_if meaning you want this field is required only if other field has a specific value.

Here, you are trying to achieve appointedd_appid is required only when isbooking_enabled has value that is 1.

BikashKatwal's avatar

@tisuchi If the code was buggy why it didn't gave me any errors locally and isbooking_enabled is also optional.

Nakov's avatar

@bikashkatwal are you running the same Laravel version both locally as on the server?

Check your error logs on what exactly is the error. storage/logs or the logs from your application server either apache or nginx whichever you use.

BikashKatwal's avatar

@bikashkatwal I tried to see the logs but the folder is empty. Only after adding messages function and calling it in controller gave me an issue.

Nakov's avatar

@bikashkatwal and the issue is what? You cannot be without any kind of log, unless you don't have permissions to the user that is hosting the app to have write permission in your storage/logs folder.

What is your APP_LOG set to? Check that one and check the item used within your config/logging.php file. Make sure you have logs.

Please or to participate in this conversation.