Why don't you use something like this
$var = isset($var) ? $var : 'default value';
I want update the nutrition detail in database. It work well, in that form all field not mandatory thats why i want assign the default value when value get null from form. Those variable value having null i want assign that some default value. Controller code is-
$workout = DB::table('nutrition') ->where('memberId', $id) ->update(['startDate' => Input::get('startDate'), 'endDate' => Input::get('endDate'), 'sunday' => Input::get('sunday'), 'sundayBrekfast' => Input::get('sundayBrekfast'), 'sundayLunch' => Input::get('sundayLunch'), 'sundayDinner' => Input::get('sundayDinner'), 'monday' => Input::get('monday'), 'mondayBrekfast' => Input::get('mondayBrekfast')]);
Please or to participate in this conversation.