jeudi 19 septembre 2019

How do I pass a formulea from a custom helper file into an Event Listener Message Body in Laravel?

I have a method for calculating volume of water as follows:

   function getVolumeM3($dgross, $land_size)
{

    return (round($dgross * $land_size));
}

Using the above formula am gettting an integer value which I want to pass it into my Event Listener.My Sample even listener is as follows.

$ta = calculateTaDuration($user->profile);
if (isset($user->phone)) {
        $message = 'Dear ' . $user->first_name . ' your plot of  '
            . $user->profile->crop->name . ' measuring '
            . $user->profile->land_area  . 'm2.'.'requires'.'354218 litres of water please open your irrigation tap for '
            . $ta . ' minutes. Thank you. The Smart Irrigator Team';

        sendSms($user->id, $user->phone, $message);

    } else {
        throw new RuntimeException('User phone is not provided');
    }

As can be seen above, I want my final sms to be as follows:

"Dear User,your plot requires M litres of water. Any help will be appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire