Stack Overflow Asked by user12332313 on November 18, 2021
I’m trying to achieve by sorting it if it is a different telecom, but it doesn’t work. Thank you in Advance. Anyways this is my code.
If you have any questions please ask me based on that I can share more details.
Controller:
$contact->telecom = getPhoneType();
Model:
public function getPhoneType() {
$s = substr($this->mobile, 0, 5);
if ($s == "63905") {
return "Globe";
}
if ($s == "63907") {
return "Smart";
}
if ($s == "63922") {
return "Sun Cellular";
}
}
The problem seems to be with the model
because it is returning value in three cases:
Solution 1:
//return some default value if none of the if condition works:
public function getPhoneType() {
$s = substr($this->mobile, 0, 5);
if ($s == "63905") {
return "Globe";
}
if ($s == "63907") {
return "Smart";
}
if ($s == "63922") {
return "Sun Cellular";
}
return "Some default value";
}
Solution 2:
Handle this on controller
side:
$phone_type = getPhoneType();
$contact->telecom = isset($phone_type) ? $phone_type : "default value" ;
Solution 3:
Presently you might be having your column like this:
Click on Change and then set some default value
Try one of the above solution!! It should work.
Answered by Ankit Jindal on November 18, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP