artsites/comments 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

artsites/comments

Composer 安装命令:

composer require artsites/comments

包简介

Comments functionality for Laravel and Nova.

README 文档

README

Installation

composer require artsites/comments

Migration

php artisan migrate

Publish

php artisan vendor:publish --provider="ArtSites\Comments\ServiceProvider" --tag="config"
php artisan vendor:publish --provider="ArtSites\Comments\ServiceProvider" --tag="js"

Optional publish

If you want to customize views, you can publish views to /resources/views/vendor/comments

php artisan vendor:publish --provider="ArtSites\Comments\ServiceProvider" --tag="views"

Also, you can publish nova resource to /app/Nova/Comment.php for adding new features fields

php artisan vendor:publish --provider="ArtSites\Comments\ServiceProvider" --tag="nova-resource"

Warning Don't forget replace namespace

Config

Path /config/comments.php

show_more_count - comments count when click show more button

ENV

This package use Google reCAPTCHA V3

For creating keys go to: https://www.google.com/recaptcha/admin/create

Please add generated keys to your env:

RECAPTCHA_SITE_KEY

RECAPTCHA_SECRET_KEY

Usage

In model that should have comments add trait

use ArtSites\Comments\Models\Traits\HasComments;

class SomeModel extends Model
{
  use HasComments;
  ...
}

Add a $comments variable to the controller that returns the view

$model = Model::first();

return view('***', [
    ...
    'model' => $model,
    'comments' => $model->getComments(),
]);

For adding template on view, you need add:

@include('comments::layout', ['comments' => $comments, 'model' => $model])

And the final touch, add HasMany relation to Nova resource

use Laravel\Nova\Fields\HasMany;

HasMany::make('Comments', 'comments', \ArtSites\Comments\Nova\Comment::class),

统计信息

  • 总下载量: 182
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-06-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固