고요빛물결

laravel-enso에도 Comments가 있네요

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

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

    });

}

 

댓글을 작성하시려면 로그인이 필요합니다.
+
분류 제목 글쓴이 날짜 조회
기타 18-10-02 조회 2,935
기타 18-09-30 조회 2,474
라라벨
[라라벨]
18-09-29 조회 3,062
라라벨 18-09-28 조회 2,027
라라벨 18-09-27 조회 7,349
기타 18-04-05 조회 2,479
라라벨 18-03-28 조회 2,873
라라벨
[라라벨]
18-03-26 조회 2,369
라라벨 18-03-25 조회 2,432
라라벨 18-03-25 조회 2,427
코드이그나이터 18-03-18 조회 3,446
라라벨 18-02-23 조회 2,102
라라벨 18-02-23 조회 2,132
기타 18-02-04 조회 2,303
라라벨 18-01-31 조회 2,314
라라벨 17-12-31 조회 2,488
기타 17-12-14 조회 2,319
일반
[일반]
17-12-13 조회 2,580
라라벨 17-11-28 조회 1,810
라라벨 17-11-23 조회 2,603
라라벨 17-11-23 조회 2,793
기타 17-11-22 조회 2,515
라라벨 17-11-21 조회 1,971
라라벨 17-11-19 조회 1,691
라라벨 17-11-17 조회 2,163
라라벨 17-11-16 조회 2,134
라라벨 17-11-15 조회 2,101
기타 17-11-14 조회 2,277
라라벨 17-11-14 조회 2,709
기타 17-11-12 조회 4,163