本文整理汇总了PHP中Conversation::fill方法的典型用法代码示例。如果您正苦于以下问题:PHP Conversation::fill方法的具体用法?PHP Conversation::fill怎么用?PHP Conversation::fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Conversation
的用法示例。
在下文中一共展示了Conversation::fill方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public function create($recipient = null)
{
$user = Confide::user();
$users = array();
$userModels = null;
if ($user->isStaff()) {
$userModels = DB::table('doctor_patient')->where('doctor_patient.staff_id', '=', $user->id)->join('user', 'doctor_patient.user_id', '=', 'user.id')->select('user.id', 'first_name', 'last_name')->get();
$users[''] = "-- Select a Patient --";
} else {
$userModels = DB::table('doctor_patient')->where('doctor_patient.user_id', '=', $user->id)->join('user', 'doctor_patient.staff_id', '=', 'user.id')->select('user.id', 'first_name', 'last_name')->get();
$users[''] = "-- Select a Doctor --";
}
// Create users array
foreach ($userModels as $userModel) {
if ($user->isStaff()) {
$users[$userModel->id] = $userModel->first_name . " " . $userModel->last_name;
} else {
$users[$userModel->id] = "Dr. " . $userModel->first_name . " " . $userModel->last_name;
}
}
if (Request::isMethod('GET')) {
return View::make('home/conversation/create', compact('user', 'users', 'recipient'));
} elseif (Request::isMethod('POST')) {
$messages = array();
$validator = Validator::make(Input::all(), array('user_id' => 'required', 'subject' => 'required', 'message' => 'required'), array('user_id.required' => 'You must select a recipient.', 'subject.required' => 'You must include a subject.', 'messages.required' => 'You must include a message.'));
// Get other errors
if ($validator->fails()) {
$messageBag = $validator->messages();
foreach ($messageBag->all(':message<br>') as $message) {
$messages[] = $message;
}
}
if (empty($messages)) {
// Create a new Appointment with the given data
$conversation = new Conversation();
$conversation->fill(Input::all());
$conversation->sender = $user->id;
$conversation->receiver = Input::get('user_id');
$conversation->save();
return Redirect::route('conversation.show.all');
} else {
// Flash data to session vars to repopulate form later
Input::flash();
// Compile error messages
$messages = implode($messages);
return Redirect::route('conversation.create')->with(array('message' => 'Error:<br>' . $messages, 'message_type' => 'error'));
}
}
}