简写if / else php不能继续

时间:2018-02-28 12:09:36

标签: php laravel if-statement laravel-5

如果第二个或第三个是假的,如何进入下一个参数事件?在我的情况下,genderfalsemarital statustrue,但它们停在gender而未执行marital status。如何让它继续下一个参数事件第二或第三个是false

public function creditScore($user, $basic_information)
    {
        $basic_information->birth_date ? dispatch(new CalculateAge($user)) : false;
        $basic_information->dependents ? dispatch(new CalculateDependents($user)) : false;
        $basic_information->education ? dispatch(new CalculateEducation($user)) : false;
        $basic_information->gender ? dispatch(new CalculateGender($user)) : false;
        $basic_information->marital_status ? dispatch(new CalculateMaritalStatus($user)) : false;
    }

1 个答案:

答案 0 :(得分:0)

使用

if (isset($basic_information->birth_date)) dispatch(new CalculateAge($user));