本文整理汇总了PHP中Comment::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::create方法的具体用法?PHP Comment::create怎么用?PHP Comment::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comment
的用法示例。
在下文中一共展示了Comment::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public function create()
{
redirect_guest_user(LOGIN_URL);
$thread = Thread::get(Param::get('thread_id'));
$page = Param::get('page_next');
$auth_user = User::getAuthenticated();
if (!$auth_user) {
return;
}
if ($page == 'create_end') {
$comment = new Comment();
$comment->body = trim(Param::get('body'));
$comment->user_id = $auth_user->id;
try {
$comment->create($thread);
$follow = Follow::getByThreadAndUser($thread->id, $comment->user_id);
if ($follow) {
$thread = Thread::get($thread->id);
$last_comment = Comment::getLastInThread($thread);
if ($last_comment) {
$follow->last_comment = $last_comment->id;
$follow->update();
}
}
redirect(VIEW_THREAD_URL, array('id' => $thread->id));
} catch (ValidationException $e) {
$page = 'create';
}
} else {
throw new PageNotFoundException();
}
$title = 'Create Comment';
$this->set(get_defined_vars());
$this->render($page);
}
示例2: run
public function run()
{
DB::table('comments')->delete();
Comment::create(['user_id' => 1, 'entry_id' => 1, 'content' => "A retravailler niveau orthographe !"]);
Comment::create(['user_id' => 2, 'entry_id' => 1, 'content' => "Nul !"]);
Comment::create(['user_id' => 1, 'entry_id' => 2, 'content' => "Sympa :-)"]);
}
示例3: run
public function run()
{
DB::table('comments')->delete();
Comment::create(array('author' => 'Nathanael Smith', 'text' => 'Look this is a new test comment'));
Comment::create(array('author' => 'D Barksdale', 'text' => 'No, the king stay the king'));
Comment::create(array('author' => 'Detective Greggs', 'text' => 'If I hear the music I\'m gunna dance'));
}
示例4: run
public function run()
{
$faker = Faker::create();
foreach (range(1, 10) as $index) {
Comment::create([]);
}
}
示例5: run
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.'));
}
示例6: test_delete_comment
public function test_delete_comment()
{
$comment = Comment::create($this->paramarray);
$id = $comment->id;
$comment->delete();
$this->assert_false(Comment::get($id));
}
示例7: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Eloquent::unguard();
Comment::create(array('user_id' => 1, 'post_id' => 1, 'body_comment' => 'This is the body for a comment'));
Comment::create(array('user_id' => 2, 'post_id' => 3, 'body_comment' => 'This is the body for a comment'));
Comment::create(array('user_id' => 3, 'post_id' => 3, 'body_comment' => 'This is the body for a comment'));
}
示例8: store
/**
* Store a newly created resource in storage.
* POST /comments
*
* @return Response
*/
public function store()
{
$data = Input::all();
$data['users_id'] = Auth::user()->id;
Comment::create($data);
return Redirect::back();
}
示例9: getOrCreateComment
protected function getOrCreateComment($wordpressID)
{
if ($wordpressID && ($comment = Comment::get()->filter(array('WordpressID' => $wordpressID))->first())) {
return $comment;
}
return Comment::create();
}
示例10: saveComment
public function saveComment()
{
$comment = Comment::create(Input::all());
$comment->user;
$comment->qpon;
$response = array("status" => "OK", "messages" => array("id" => 1, "message" => "Comment was saved succesfully..."), "comment" => $comment->toArray());
return Response::json($response);
}
示例11: add_comment
public function add_comment($author_name, $content)
{
try {
Comment::create($this->_id, $author_name, $content);
} catch (Exception $e) {
die($e->getMessage());
}
}
示例12: run
public function run()
{
$comment = array('コメントやで', 'コメントだよ', 'コメントでおま', 'コマントなのです!', 'コメント5', 'コメント6', 'コメントやで', 'コメントだよ4', 'コメントでおま4', 'コマントなのです!2', 'コメントだよ2');
$now = date('Y-m-d H:i:s');
foreach ($comment as $c) {
Comment::create(array('user_id' => mt_rand(1, 4), 'item_id' => mt_rand(1, 8), 'comment' => $c, 'created_at' => $now, 'updated_at' => $now));
}
}
示例13: testNewRecordWithNewReferenced
public function testNewRecordWithNewReferenced()
{
$page = Page::create(array("name" => "English article", "description" => "Description", "text" => "Text in english.", "allowed" => true));
$page->Comments[] = Comment::create(array("text" => "muj názor", "name" => "Honza", "mail" => "muj@mail.cz"));
$page->Comments[] = Comment::create(array("text" => "muj jiný názor", "name" => "Honza", "mail" => "muj@mail.cz"));
$page->save();
$this->assertEquals(2, count(Page::findByName("English article")->Comments));
}
示例14: run
public function run()
{
DB::table('comments')->delete();
Comment::create(array('content' => '这医生好帅哦,虽然没阿登帅', 'record_id' => 4));
Comment::create(array('content' => '这医生好帅哦,虽然没阿登帅', 'record_id' => 3));
Comment::create(array('content' => '这医生好帅哦,虽然没阿登帅', 'record_id' => 2));
Comment::create(array('content' => '这医生好帅哦,虽然没阿登帅', 'record_id' => 1));
}
示例15: create
/**
* Create and store new comment.
*
* @param array $data
* @return \FIIP\Comments\Comment|null
*/
public function create(array $data)
{
$comment = Comment::create($data);
if (!$comment->id) {
return null;
}
return $this->find($comment->id);
}