当前位置: 首页>>代码示例>>PHP>>正文


PHP Comment::create方法代码示例

本文整理汇总了PHP中app\Comment::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::create方法的具体用法?PHP Comment::create怎么用?PHP Comment::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Comment的用法示例。


在下文中一共展示了Comment::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::Create();
     foreach (range(1, 10) as $seededItem) {
         User::create(['first_name' => $faker->name, 'last_name' => $faker->name, 'password' => Hash::make('123456'), 'type' => false, 'sex' => $faker->boolean(), 'email' => $faker->email, 'date_of_birth' => $faker->date('Y-m-d')]);
     }
     $users = User::all()->lists('id')->toArray();
     foreach (range(1, 100) as $seededItem) {
         Post::create(['user_id' => $faker->randomElement($users), 'body' => $faker->text, 'vote_count' => 0]);
     }
     $posts = Post::all()->lists('id')->toArray();
     Comment::create(['user_id' => $faker->randomElement($users), 'body' => $faker->text, 'vote_count' => 0, 'parent_id' => null]);
     foreach (range(1, 100) as $seededItem) {
         Post_Vote::create(['user_id' => $faker->randomElement($users), 'post_id' => $faker->randomElement($posts), 'up' => $faker->boolean()]);
         Comment::create(['user_id' => $faker->randomElement($users), 'parent_id' => $faker->randomElement(Comment::all()->lists('id')->toArray()), 'post_id' => $faker->randomElement($posts), 'body' => $faker->text, 'vote_count' => 0]);
         Tag::create(['name' => $faker->text, 'private' => $faker->boolean()]);
     }
     $comments = Comment::all()->lists('id')->toArray();
     $tags = Tag::all()->lists('id')->toArray();
     foreach (range(1, 100) as $seededItem) {
         Comment_Vote::create(['user_id' => $faker->randomElement($users), 'comment_id' => $faker->randomElement($comments), 'up' => $faker->boolean()]);
         Tag_User::create(['user_id' => $faker->randomElement($users), 'tag_id' => $faker->randomElement($tags)]);
         Post_Tag::create(['tag_id' => $faker->randomElement($tags), 'post_id' => $faker->randomElement($posts)]);
     }
 }
开发者ID:khaled-barca,项目名称:MyTunnelVision,代码行数:30,代码来源:TableSeeder.php

示例2: run

 public function run()
 {
     DB::table('comments')->delete();
     Comment::create(['author' => '山本さん', 'text' => '今日は良い天気ですね']);
     Comment::create(['author' => '山田さん', 'text' => 'お久しぶりです']);
     Comment::create(['author' => '竹下さん', 'text' => '便利ですね。']);
 }
开发者ID:ryamamoto,项目名称:laravel5-sample-angularjs-commentlist,代码行数:7,代码来源:CommentTableSeeder.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['content' => 'required']);
     $input = $request->all();
     Comment::create(array_merge($input, ['user_id' => Auth::user()->id]));
     return redirect(url('articles', $input['article_id']));
 }
开发者ID:Aylchen,项目名称:laravel5,代码行数:13,代码来源:CommentController.php

示例4: store

 /**
  * Store a newly created resource in storage.
  * @param CreateCommentRequest $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateCommentRequest $request)
 {
     //validation
     //$input = Request::all();
     Comment::create($request->all());
     return redirect('comment');
 }
开发者ID:Rainlonely,项目名称:rainlonely,代码行数:12,代码来源:ContactController.php

示例5: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //
     $comment = Request::all();
     Comment::create($comment);
     return redirect('threadforum.comment');
 }
开发者ID:roardi,项目名称:ForumProject,代码行数:13,代码来源:CommentController.php

示例6: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CommentRequest $request)
 {
     Comment::create($request->all());
     // return view('prayers.show');
     // return \Redirect::back()->with('message','Comment saved.');
     return redirect('prayers');
 }
开发者ID:aflashyrhetoric,项目名称:pray,代码行数:13,代码来源:CommentsController.php

示例7: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('comments')->delete();
     Comment::create(array('author' => 'Chris Sevilleja', 'text' => 'Look I am a test comment.'));
     Comment::create(array('author' => 'Nick Cerminara', 'text' => 'This is going to be super crazy.'));
     Comment::create(array('author' => 'Holly Lloyd', 'text' => 'I am a master of Laravel and Angular'));
 }
开发者ID:paxian,项目名称:commentapp,代码行数:12,代码来源:CommentTableSeeder.php

示例8: store

 public function store(BookingRequest $request)
 {
     $booking = array('car_type_id' => $request->car_type_id, 'number_of_passengers' => $request->number_of_passengers, 'pickup_time' => $request->pickup_date_part . ' ' . $request->pickup_time_part, 'ip_info' => $request->ip_info);
     $newBooking = Booking::create($booking);
     flash()->success('Your booking has been created!')->important();
     if (!empty($request->comment1)) {
         //children comment
         $comment1 = array('booking_id' => $newBooking->id, 'comment_type_id' => '1', 'role_id' => '1', 'comment' => $request->comment1);
         Comment::create($comment1);
     }
     if (!empty($request->comment2)) {
         //general comment
         $comment2 = array('booking_id' => $newBooking->id, 'comment_type_id' => '2', 'role_id' => '1', 'comment' => $request->comment2);
         Comment::create($comment2);
     }
     $change = array('booking_id' => $newBooking->id, 'change_type_id' => '4', 'user_id' => Auth::user()->id, 'from' => null, 'to' => null);
     Change::create($change);
     $passenger = User::firstOrNew(['email' => $request->email]);
     $passenger->name = $request->name;
     $passenger->phone = $request->phone;
     $passenger->save();
     $role = array('booking_id' => $newBooking->id, 'role_type_id' => '2', 'user_id' => $passenger->id);
     Role::create($role);
     $price = array('booking_id' => $newBooking->id, 'income_type_id' => '1', 'amount_eur' => $request->price);
     Income::create($price);
     $locationArray = $request->location;
     foreach ($request->address as $order => $address_id) {
         $route_point = null;
         $route_point = array('booking_id' => $newBooking->id, 'location_id' => $locationArray[$order], 'address_id' => $address_id, 'order' => $order);
         Route_point::create($route_point);
     }
     return redirect('bookings');
 }
开发者ID:jedlicka82,项目名称:transferpraha,代码行数:33,代码来源:BookingController.php

示例9: postComment

 public function postComment(Category $category, Post $post, CommentRepository $repository, PostNewComment $request, Comment $comment)
 {
     $fields = array_merge($request->all(), array('post_id' => $post->id));
     $comment->create($fields);
     Session::flash('success', 'Comment added succesfully !');
     return view('blog.post', ['post' => $post, 'categories' => $category->all()]);
 }
开发者ID:bigpaulie,项目名称:demo-laravel-blog,代码行数:7,代码来源:BlogController.php

示例10: up

 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     $u = User::create(['first_name' => 'test', 'last_name' => 'test', 'email' => 'test@test.fr', 'level' => 1]);
     $u2 = User::create(['first_name' => 'test2', 'last_name' => 'test2', 'email' => 'test2@test.fr', 'level' => 1]);
     $u3 = User::create(['first_name' => 'test3', 'last_name' => 'test3', 'email' => 'test3@test.fr', 'level' => 2]);
     $e1 = Event::create(['name' => 'test event', 'user_id' => 3, 'slug' => 'test-event-1', 'date' => '2016-10-17', 'start' => '18:00:00', 'end' => '5:00:00']);
     $e2 = Event::create(['name' => 'test event', 'user_id' => 1, 'slug' => 'test-event-2', 'date' => '2016-08-22', 'start' => '19:00:00', 'end' => '5:00:00']);
     Event::create(['name' => 'test event', 'user_id' => 2, 'slug' => 'test-event-3', 'date' => '2017-01-07', 'start' => '18:00:00', 'end' => '5:00:00']);
     $p1 = Playlist::create(['name' => 'Playlist principale !']);
     $p2 = Playlist::create(['name' => 'The Playlist !']);
     $p3 = Playlist::create(['name' => 'Playlist secondaire']);
     Playlist::create(['name' => 'The Playlist !']);
     $p1->styles()->sync([1, 2, 3]);
     $p2->styles()->sync([1, 4]);
     $p3->styles()->sync([1, 3, 5, 7]);
     $e1->playlists()->sync([1, 3]);
     $e2->playlists()->sync([2]);
     Comment::create(['event_id' => 2, 'user_id' => 2, 'content' => 'Sooo goooood']);
     Comment::create(['event_id' => 3, 'user_id' => 2, 'content' => 'Sooo goooood :D']);
     Comment::create(['event_id' => 2, 'user_id' => 3, 'content' => 'Sooo goooood !!!']);
     Video::create(['url' => '7l48bfQuJeE', 'artist' => 'Chill Bump', 'name' => 'Lost In The Sound', 'tags' => 'chill bump lost in the sound']);
     Video::create(['url' => 'XxdPJvhQaMU', 'artist' => 'Chill Bump', 'name' => 'Water boycotter', 'tags' => 'chill bump water boycotter']);
     Video::create(['url' => 'kWXAYDQ_K7k', 'artist' => 'Chill Bump', 'name' => 'The Memo', 'tags' => 'chill bump the memo']);
     $pivot1 = $p1->videos()->sync([1, 3]);
     $pivot2 = $p2->videos()->sync([2]);
     $pivot3 = $p3->videos()->sync([1, 2, 3]);
     News::create(['title' => 'news test', 'content' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ', 'user_id' => 2, 'slug' => 'text-news-1']);
     News::create(['title' => 'news test 2', 'content' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ', 'user_id' => 3, 'slug' => 'text-news-2']);
     Article::create(['title' => 'Article test 1', 'content' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ', 'user_id' => 2, 'slug' => 'text-article-1']);
     Article::create(['title' => 'Article test 2', 'content' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ', 'user_id' => 3, 'slug' => 'text-article-2', 'event_id' => 2]);
 }
开发者ID:Techraav,项目名称:djMaker,代码行数:36,代码来源:2017_06_10_032123_create_base_entries.php

示例11: store

 public function store(Request $request)
 {
     $article = Article::find($request->article_id);
     if (empty($article)) {
         return response()->json(['status' => 404, 'msg' => '文章不存在']);
     }
     if (!$article->comment_status) {
         return response()->json(['status' => 403, 'msg' => '文章已禁用评论']);
     }
     $rules = array('body' => 'required');
     $validation = Validator::make($commentData = $request->all(), $rules);
     if ($validation->fails()) {
         return response()->json(['status' => 0, 'msg' => '评论内容不能为空']);
     }
     $user = Auth::user();
     $commentData['user_id'] = $user->id;
     $parsedComment = parseAt($commentData['body']);
     $atUidArr = $parsedComment['uidArr'];
     $commentData['body'] = Markdown::parse($parsedComment['comments']);
     $comment = Comment::create($commentData);
     $html = view('articles._comment', compact('comment'))->render();
     $comment->article->increment('comment_count');
     $user->histories()->create(['type' => 'comment', 'content' => '评论文章《<a href="/article/' . $article->id . '#comment-' . $comment->id . '" target="_blank">' . $article->title . '</a>》']);
     Notify::notify([$article->user_id], '<a href="/user/' . $user->id . '" target="_blank">' . $user->name . '</a> 评论了您的文章 <a href="/article/' . $article->id . '#comment-' . $comment->id . '" target="_blank">' . $article->title . '</a>', 'comment');
     if ($atUidArr) {
         Notify::notify($atUidArr, '<a href="/user/' . $user->id . '" target="_blank">' . $user->name . '</a> 在文章 <a href="/article/' . $article->id . '#comment-' . $comment->id . '" target="_blank">' . $article->title . '</a> 的评论中提到了您', 'comment');
     }
     return response()->json(['status' => 200, 'msg' => '评论成功', 'html' => $html]);
 }
开发者ID:misterebs,项目名称:cmsku,代码行数:29,代码来源:CommentController.php

示例12: comment

 public function comment($id, Request $request)
 {
     $post = \App\Post::find($id);
     $comment = \App\Comment::create($request->all());
     $post->comments()->save($comment);
     return redirect()->route('posts.show', $post->id);
 }
开发者ID:hsaung,项目名称:formrequest,代码行数:7,代码来源:PostsController.php

示例13: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     //
     for ($i = 1; $i < 50; $i++) {
         Comment::create(['user_id' => rand(1, 30), 'post_id' => rand(1, 50), 'body' => 'comment body' . $i, 'status' => 1]);
     }
 }
开发者ID:shine1rainbow,项目名称:blog,代码行数:12,代码来源:CommentTableSeeder.php

示例14: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Requests\StoreCommentRequest $request)
 {
     if (Comment::create($request->all())) {
         return Redirect::back();
     } else {
         return Redirect('/');
     }
 }
开发者ID:borghan,项目名称:Laravel_Blog,代码行数:14,代码来源:CommentController.php

示例15: store

 public function store(Request $request)
 {
     $user_id = User::find(1);
     $video_id = $request->input('video_id');
     $text = $request->input('message');
     Comment::create(['user_id' => $user_id->id, 'video_id' => $video_id, 'text' => $text]);
     return redirect()->back();
 }
开发者ID:anrito,项目名称:video,代码行数:8,代码来源:CommentsController.php


注:本文中的app\Comment::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。