本文整理匯總了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'));
}
}
}