Package Data | |
---|---|
Maintainer Username: | christianvizarra |
Maintainer Contact: | hello@draperstudio.tech (DraperStudio) |
Package Create Date: | 2016-10-19 |
Package Last Update: | 2016-10-19 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-02-10 15:03:50 |
Package Statistics | |
---|---|
Total Downloads: | 28 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Via Composer
$ composer require christianvizarra/laravel-commentable
And then include the service provider within app/config/app.php
.
'providers' => [
DraperStudio\Commentable\ServiceProvider::class
];
At last you need to publish and run the migration.
php artisan vendor:publish --provider="DraperStudio\Commentable\ServiceProvider" && php artisan migrate
<?php
/*
* This file is part of Laravel :package_name.
*
* (c) DraperStudio <hello@draperstudio.tech>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App;
use DraperStudio\Commentable\Contracts\Commentable;
use DraperStudio\Commentable\Traits\Commentable as CommentableTrait;
use Illuminate\Database\Eloquent\Model;
class Post extends Model implements Commentable
{
use CommentableTrait;
}
$user = User::first();
$post = Post::first();
$comment = $post->comment([
'title' => 'Some title',
'body' => 'Some body',
], $user);
dd($comment);
$user = User::first();
$post = Post::first();
$parent = $post->comments->first();
$comment = $post->comment([
'title' => 'Some title',
'body' => 'Some body',
], $user, $parent);
dd($comment);
$comment = $post->updateComment(1, [
'title' => 'new title',
'body' => 'new body',
]);
$post->deleteComment(1);
$post = Post::first();
dd($post->getCommentCount());
Please see CHANGELOG for more information what has changed recently.
$ composer test
Please see CONTRIBUTING and CONDUCT for details.
If you discover any security related issues, please email hello@draperstudio.tech instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
=======
forked of draperstudio/laravel-commentable