本文整理汇总了PHP中app\Message::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::toArray方法的具体用法?PHP Message::toArray怎么用?PHP Message::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Message
的用法示例。
在下文中一共展示了Message::toArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postContact
public function postContact(ContactFormRequest $request)
{
$data = new Message($request->name, $request->email, explode("\n", $request->get('message')));
Mail::send('emails.contact', $data->toArray(), function ($message) use($data) {
$message->subject('CSC Company Formulario de contáctenos: ' . $data->name)->to(Message::ORGANIZATION_EMAIL)->replyTo($data->email);
});
return back()->withMessage("Gracias por su mensaje. Ha sido enviado.");
}
示例2: store
/**
* Store a newly created message in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
// Create the custom validator for a message post
$validator = Validator::make($request->all(), ['message' => 'min:5|required']);
// If validation fails
if ($validator->fails()) {
return response()->json(['success' => false, 'message' => 'Validation Failed', 'errors' => $validator->errors()->all()], self::JSON_INVALID_REQUEST_STATUS_CODE);
}
// Store the new message
$message = new SalmanMessage();
$message->name = $request->get('name');
$message->mobile_number = $request->get('mobile_number');
$message->email = $request->get('email');
$message->message = $request->get('message');
$message->ip = request()->ip();
$message->save();
return response()->json(['success' => true, 'message' => 'New Message Submitted!', 'resource' => $message->toArray()]);
}