本文整理汇总了PHP中app\Message::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::create方法的具体用法?PHP Message::create怎么用?PHP Message::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Message
的用法示例。
在下文中一共展示了Message::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createMessageNode
public function createMessageNode()
{
$input = Request::all();
//return $input;
$app_id = '137227';
// App ID
$app_key = '86b7e1c9f40657708bf4';
// App Key
$app_secret = '48a7047a11529259b2cc';
// App Secret
$pusher = new Pusher($app_key, $app_secret, $app_id);
$data['message'] = $input[2];
$data['uid'] = $input[0];
$data['crid'] = $input[1];
$formdata['uid'] = $data['uid'];
$formdata['crid'] = $data['crid'];
$formdata['content'] = $data['message'];
$channel = "my" . $data['crid'];
if ($pusher->trigger($channel, 'my_event', $data)) {
echo 'success';
Message::create($formdata);
} else {
echo 'error';
}
//return $input;
}
示例2: handle
/**
* Handle the event.
*
* @param Events $event
* @return void
*/
public function handle(ChatEvent $event)
{
$message = Message::create(['message' => $event->getMessage()]);
// $message->chat()->associate($event->getChat());
$event->getChat()->messages()->save($message);
// echo "\n{$message->message}";
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
for ($i = 1; $i < 40; $i++) {
Message::create(['user_id' => rand(1, 30), 'body' => 'text' . $i]);
}
}
示例4: handle
/**
* Execute the command.
*
* @return void
*/
public function handle()
{
$message = Message::create($this->data);
$this->user->messages()->save($message);
$this->chat->messages()->save($message);
event(new FeedableEvent('MessagePosted', $this->user, $message, $this->chat, $this->chat->project));
return $message;
}
示例5: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$faker = Faker::create();
$userIds = DB::table('users')->where('id', '!=', 1)->lists('id');
foreach (range(1, 25) as $index) {
Message::create(['body' => $faker->sentence(), 'senderprofileimage' => $faker->imageUrl($width = 180, $height = 180), 'senderid' => $faker->randomElement($userIds), 'sendername' => $faker->firstName]);
}
}
示例6: store
public function store(Request $request)
{
$this->validate($request, ['name' => 'required', 'email' => 'required|email', 'subject' => 'required', 'message' => 'required']);
$message = $request->all();
$message['user_id'] = Auth::user()->id;
Message::create($message);
return \Redirect('/dashboard')->with(['alert-success' => 'Message Successfully Sent !']);
}
示例7: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$user = null;
if (isset($request['message'])) {
$user = Message::create(['message' => $request['message']]);
}
return json_encode(['message' => is_null($user) ? 'Failed' : 'Success']);
}
示例8: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
$messages = ['required' => ':attribute harus diisi.'];
$this->validate($request, ['name' => 'required|min:3', 'hp' => 'required|min:6', 'email' => 'required', 'subject' => 'required', 'message' => 'required|max:1024'], $messages);
flash()->success('Pesan anda telah kami terima!');
Message::create($request->all());
return redirect('/kontak');
}
示例9: store
public function store(Request $request)
{
$validator = Validator::make($request->all(), ['creator' => 'required', 'email' => 'required', 'body' => 'required']);
if ($validator->fails()) {
return response()->json($validator->errors()->all(), 422);
}
return Message::create($request->all());
}
示例10: storeMessage
public function storeMessage($user, $input)
{
$thread = Thread::create(['subject' => $input['subject']]);
Message::create(['thread_id' => $thread->id, 'user_id' => Auth::user()->id, 'body' => $input['message']]);
Participant::create(['thread_id' => $thread->id, 'user_id' => Auth::user()->id, 'last_read' => new Carbon()]);
Participant::create(['thread_id' => $thread->id, 'user_id' => $user->id, 'last_read' => new Carbon()]);
$this->sentMessageNotification($user);
}
示例11: store
public function store(MessageRequest $request)
{
try {
\App\Message::create($request->all());
return response()->json(['errors' => 'false', 'message' => 'The project has been added!']);
} catch (\Exception $e) {
return response()->json(['errors' => 'true', 'message' => 'Something went wrong!']);
}
}
示例12: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$this->validate($request, ['message' => 'required|min:2|max:300']);
$data = $request->all();
$data['userID'] = \Auth::id();
$data['parentID'] = $id;
Message::create(['message' => $data['message'], 'userID' => $data['userID'], 'parentID' => $data['parentID'], 'createdDate' => Carbon::now()]);
return redirect('message')->with(['flash_message' => 'Your reply has been added!']);
}
示例13: contactUs
public function contactUs(Request $request)
{
$rules = ['email' => 'required|email', 'subject' => 'required', 'contact' => 'required', 'message' => 'required'];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return redirect()->back()->with('errors', $validator->messages());
}
Message::create(array_except($request->all(), ['_token']));
return redirect('/contact-us')->withMessage('Message Sent.');
}
示例14: store
/**
* Almacena un nuevo mensaje en nuestra tabla messages
*
* @param MessageRequest $request -> valida los campos requeridos para crear un mensaje
* @return \Illuminate\Http\Response
*/
public function store(MessageRequest $request)
{
/* $request->all() trae la información que se ingresó en la forma */
/* Message::create() crea el nuevo record y lo almacena en la tabla messages */
Message::create($request->all());
/* Feedback para el usuario, le indiciamos que su mensaje a sido enviados */
Session::flash('flash_message', 'Ha enviado un mensaje');
/* redirige a la pagina de contacto y muestra el Session::flash */
return redirect('contact');
}
示例15: contactMe
public function contactMe(MessageRequest $request)
{
$request->input('title');
$result = \Mail::raw(Input::get('message'), function ($message) {
$message->to('shaopeihui1@gmail.com', 'Peihui Shao')->subject('Message from ' . Input::get('email') . ', ' . Input::get('user'));
});
Message::create($request->all());
// flash()->info( var_dump($result)); //not working
flash()->success('Your message has been delivered and saved!');
return Redirect::back();
}