我对使用Cache :: has(' variable')的条件行为非常困惑。它应该打印 A 然后 B 或 C 然而它只是 A 调试时我能看到的内容。似乎有条件的if(Cache::has($chat_id)) {
被忽略了。问题是什么?
if($purpose == 'chat'){
$action = 2;//chat
error_log('A');
if(Cache::has($chat_id)) {
error_log('B');
} else {
error_log('C');
$chat = Chat::select('user_id', 'employer_id')->where('_id',$chat_id)->first();
$user = User::select('email')->where('_id', $chat->user_id)->first();
$employer = User::select('contact_name')->where('_id', $chat->employer_id)->first();
$template=EmailTemplate::find('5a7af73cd40aaf098d6f7dc1');
$find=array('@name@','@employer_name@');
$values=array($user->email, $employer->contact_name);
$body=str_replace($find,$values,$template->content);
sendMail($user->email,$body,$template,'Tienes un mensaje de chat nuevo');
// 1440 minutes = 1 day.
//Cache::add($chat_id, true, 1440);
}
}
elseif($purpose == 'interview_cancelled'){
$action = 3; //interview_cancelled
}
elseif($purpose == 'interview'){
$action = 4; //interview proposed
}
答案 0 :(得分:0)
在文件顶部添加public class IPHistoryListPreference extends ListPreference {
SharedPreferences sharedPref;
public IPHistoryListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
}
public IPHistoryListPreference(Context context) {
super(context);
sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
}
@Override
protected View onCreateDialogView() {
ListView view = new ListView(getContext());
view.setAdapter(adapter());
}
private ListAdapter adapter() {
return new ArrayAdapter(getContext(), android.R.layout.select_dialog_singlechoice);
}
private CharSequence[] entries() {
//convert sharedPref stringSet to CharSequence[] ?
}
private CharSequence[] entryValues() {
//convert sharedPref stringSet to CharSequence[] ?
}
}
。我不知道为什么laravel没有向我显示导入错误。