고요빛물결

laravel-enso에도 Comments가 있네요

· 2019-01-14 (월) 00:15:12 · 1889

라라벨의 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']);

    });

}

 

댓글을 작성하시려면 로그인이 필요합니다.
+
분류 제목 글쓴이 날짜 조회
라라벨 17-11-11 조회 2,324
라라벨 17-11-10 조회 2,119
라라벨 17-11-07 조회 3,044
기타 17-10-31 조회 2,416
기타 17-10-30 조회 1,801
라라벨
[라라벨]
17-10-29 조회 1,917
기타 17-10-28 조회 2,308
기타 17-10-28 조회 1,914
라라벨 17-10-27 조회 3,605
기타 17-10-03 조회 3,157
기타 17-09-21 조회 2,224
라라벨 17-09-21 조회 2,438
라라벨 17-09-20 조회 2,489
라라벨 17-09-01 조회 2,434
라라벨
[라라벨]
17-06-30 조회 1,823
코드이그나이터 17-06-25 조회 2,916
코드이그나이터 17-06-23 조회 2,263
코드이그나이터 17-06-22 조회 2,878
라라벨 17-06-20 조회 3,319
일반 17-06-15 조회 1,978
일반 17-06-10 조회 2,406
기타 17-06-09 조회 2,750
라라벨 17-05-15 조회 1,815
라라벨 17-05-15 조회 1,841
라라벨 17-05-15 조회 1,926
기타 17-05-10 조회 1,961
기타 17-04-11 조회 2,117
라라벨 17-04-11 조회 2,570
라라벨 17-04-11 조회 1,862
기타 17-04-10 조회 2,162