고요빛물결

laravel-enso에도 Comments가 있네요

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

라라벨의 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-04-09 조회 3,357
라라벨 17-04-08 조회 2,950
라라벨 17-04-07 조회 2,526
라라벨 17-04-07 조회 2,542
라라벨 17-04-06 조회 4,198
라라벨 17-04-06 조회 3,651
라라벨 17-04-06 조회 2,518
라라벨 17-04-05 조회 1,915
라라벨 17-04-05 조회 1,953
라라벨 17-04-03 조회 1,718
라라벨 17-04-03 조회 1,752
라라벨 17-04-02 조회 1,826
라라벨 17-04-02 조회 2,001
라라벨
[라라벨]
17-04-01 조회 1,812
라라벨 17-03-31 조회 1,665
라라벨 17-03-31 조회 2,599
라라벨 17-03-31 조회 1,977
라라벨 17-03-30 조회 2,351
라라벨 17-03-29 조회 1,991
라라벨 17-03-28 조회 2,268
라라벨 17-03-27 조회 2,090
라라벨 17-03-26 조회 1,816
라라벨 17-03-25 조회 1,803
라라벨 17-03-24 조회 1,957
라라벨 17-03-23 조회 3,964
일반 17-03-15 조회 1,853
라라벨 17-03-07 조회 4,253
라라벨 17-03-06 조회 1.4만
일반
[일반]
17-02-24 조회 2,011
일반 17-02-23 조회 1,959