當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。