承接 andach/laravel-attachments-comments 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

andach/laravel-attachments-comments

最新稳定版本:v1.0.1

Composer 安装命令:

composer require andach/laravel-attachments-comments

包简介

This is a Laravel package to allow you to add comments and attachments to models.

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This is a Laravel package for adding Attachments and Comments to any model.

Installation

You can install the package via composer:

composer require andach-limited/laravel-attachments-comments

You should then publish the config and migrations with:

php artisan attachments-comments:install

Usage

Using a Trait

To add the relations to a model, simply add the MorphToAttachmentsAndComments trait to the model. If only one is needed, then just use MorphToAttachments or MorphToComments by themselves.

class MyModel extends Model
{
    use MorphToAttachmentsAndComments;

    // ...
}

Adding Attachments and/or Comments

To actually add an attachment or a comment, you can use the addAttachmentAndComment(). This accepts a single string and an optional UploadedFile.

<form action="{{ route('my-model.store') }}" method="POST" enctype="multipart/form-data">
    @csrf

    <input type="text" name="comment" />
    <input type="file" name="attachment" />

    <button type="submit">Submit</button>
</form>

And in the relevant controller method...

public function store(Request $request)
{
    $model = MyModel::create();

    $model->addAttachmentAndComment($request->comment, $request->attachment);

    return redirect()->route('my-model.show', $model);
}

If handed an empty string or null attachment, the system will not create an attachment or comment silently.

Retrieving Attachments and Comments

The relations are all handled by the traits, so you can just call:

$model = new MyModel();

foreach ($model->attachments as $attachment)
{
    // ...
}

foreach ($model->comments as $comment)
{
    // ...
}

Displaying Comments and Attachments


License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-09-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固