TIP 55 / 73

Simplify If on a Request with Whenfilled() Helper.

We often write if statements to check if a value is present on a request or not.

You can simplify it with the whenFilled() helper.

code
public function store(Request $request)
{
    $request->whenFilled('status', function (string $status)) {
        // Handle the provided status here.
    }, function () {
        // This callback runs when the status is not provided.
    });
}