고요빛물결

laravel-enso에도 Comments가 있네요

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

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

    });

}

 

댓글을 작성하시려면 로그인이 필요합니다.
+
분류 제목 글쓴이 날짜 조회
라라벨 19-01-09 조회 1,771
라라벨 19-01-08 조회 2,035
라라벨 19-01-08 조회 1,601
라라벨 19-01-08 조회 1,613
라라벨 19-01-07 조회 2,270
라라벨 19-01-06 조회 2,143
기타 19-01-05 조회 2,286
라라벨 19-01-04 조회 1,789
라라벨 19-01-04 조회 1,681
라라벨 19-01-04 조회 4,515
라라벨 19-01-03 조회 1,813
라라벨 19-01-03 조회 2,997
라라벨 19-01-02 조회 1,838
라라벨 19-01-01 조회 2,159
라라벨 18-12-31 조회 2,139
라라벨
[라라벨]
18-12-30 조회 1,615
라라벨 18-12-30 조회 2,612
기타 18-12-30 조회 1,580
라라벨 18-12-29 조회 1,959
코드이그나이터 18-12-28 조회 1,728
일반 18-12-28 조회 1,701
라라벨 18-12-27 조회 1,810
라라벨 18-12-26 조회 2,591
라라벨 18-12-25 조회 1,744
라라벨 18-12-23 조회 1,727
라라벨 18-12-20 조회 2,312
기타 18-10-07 조회 2,209
라라벨 18-10-05 조회 1,955
기타 18-10-04 조회 2,509
기타 18-10-03 조회 2,348