Package Data | |
---|---|
Maintainer Username: | alex-oliveira |
Package Create Date: | 2017-05-29 |
Package Last Update: | 2017-05-30 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-14 15:11:10 |
Package Statistics | |
---|---|
Total Downloads: | 8 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
$ composer require alex-oliveira/ao-comments
'providers' => [
/*
* Vendor Service Providers...
*/
AoComments\ServiceProvider::class,
],
return [
.
.
.
'models' => [
'users' => App\Models\User::class,
],
'tables' => [
'users' => 'users'
]
.
.
.
];
$ php artisan vendor:publish
$ composer dump
public function up()
{
AoComments()->schema()->create('posts');
}
the same that
public function up()
{
Schema::create('ao_comments_x_posts', function (Blueprint $table) {
$table->integer('post_id')->unsigned();
$table->foreign('post_id', 'fk_posts_x_ao_comments')->references('id')->on('posts');
$table->bigInteger('comment_id')->unsigned();
$table->foreign('comment_id', 'fk_ao_comments_x_posts')->references('id')->on('ao_comments_comments');
$table->primary(['post_id', 'comment_id'], 'pk_ao_comments_x_posts');
});
}
public function down()
{
AoLogs()->schema()->drop('posts');
}
the same that
public function down()
{
Schema::dropIfExists('ao_comments_x_posts');
}
namespace App\Models;
use AoComments\Models\Comment;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
/**
* @return Comment[]|\Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function comments()
{
return $this->belongsToMany(Comment::class, AoComments()->schema()->table($this->getTable()));
}
}
the same that
return $this->belongsToMany(Comment::class, 'ao_comments_x_posts');
namespace App\Http\Controllers\Posts;
use AoComments\Controllers\AoCommentsController;
use App\Models\Post;
class CommentsController extends AoCommentsController
{
protected $dynamicClass = Post::class;
}
Route::group(['prefix' => 'posts', 'as' => 'posts.'], function () {
AoComments()->router()->controller('Posts\CommentsController')->foreign('post_id')->make();
.
.
.
});
$ php artisan route:list