Hi everyone i have a question how can i display the subject based on the user status. if the user is active which means the the full subject will be displayed but if he is not active i only want to display specific subject.
public function inquirySubject()
{
if(auth()->user()->status === 'approved' || auth()->user()->status === 'active')
{
$subject = [
'Inquiry',
'Follow Up',
'Technical Problem',
'Other Application Concern',
'Payment Concern' ,
'Proof of Payment'
];
}else{
$subject = [
'Inquiry',
'Follow Up',
'Technical Problem',
'Other Application Concern',
// 'Payment Concern' , // if user is not active or approved this subject line should not display
'Proof of Payment'
];
}
return response()->json($subject);
}
2
Answers
You could do something like this to save a bit of code duplication:
You could also implement this logic in a Resource – see: https://laravel.com/docs/9.x/eloquent-resources
Add to model
And
Your function