laravel-enso에도 Comments가 있네요 > PHP프레임워크

PHP프레임워크

laravel-enso에도 Comments가 있네요 정보

라라벨 laravel-enso에도 Comments가 있네요

본문

라라벨의 package를 사용해서 만든 것 같습니다.

 

https://github.com/laravel-enso/CommentsManager

 

vendor로 등록되는 구조이니..  라라벨에서 메인 코어는 나눠도 각각 패키지별로 업그레이드가 편하게 

 

할 수 있을 것 같습니다.

 

morphs를 잘 이해해야 되네요

 

CommentsTable

 

public function up()

{

  Schema::create('comments', function (Blueprint $table) {

    $table->increments('id');

 

    $table->morphs('commentable');

 

    $table->text('body');

 

    $table->integer('created_by')->unsigned()->nullable();

    $table->foreign('created_by')->references('id')->on('users');

 

    $table->integer('updated_by')->unsigned()->nullable();

    $table->foreign('updated_by')->references('id')->on('users');

 

    $table->timestamps();

  });

}

 

CommentUserPivotTable

public function up()

{

    Schema::create('comment_user', function (Blueprint $table) {

        $table->integer('comment_id')->unsigned()->index();

        $table->foreign('comment_id')->references('id')->on('comments')

            ->onDelete('cascade');

 

        $table->integer('user_id')->unsigned()->index();

        $table->foreign('user_id')->references('id')->on('users')

            ->onDelete('cascade');

 

        $table->primary(['comment_id', 'user_id']);

    });

}

 

추천
0
  • 복사

댓글 0개

© SIRSOFT
현재 페이지 제일 처음으로