定制 shaka/dynamic-update-trait 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

shaka/dynamic-update-trait

最新稳定版本:v1.0.1

Composer 安装命令:

composer require shaka/dynamic-update-trait

包简介

The Dynamic Update Trait for Laravel provides a convenient way to dynamically update model attributes using magic methods. This trait allows you to update individual model attributes without explicitly defining setter methods for each attribute. It simplifies the process of updating model fields by

README 文档

README

The Dynamic Update Trait for Laravel provides a convenient way to dynamically update model attributes using magic methods. This trait allows you to update individual model attributes without explicitly defining setter methods for each attribute. It simplifies the process of updating model fields by providing a generic update method that can be called with dynamic method names.

Installation

You can install the package via Composer:

composer require shaka/dynamic-update-trait

Usage

To use the Dynamic Update Trait, simply use it in your Eloquent model:

<?php
 
namespace App\Models;
 
use Illuminate\Database\Eloquent\Model;
use Shaka\DynamicUpdateTrait\Traits\DynamicUpdateTrait;


class User extends Model
{
  use DynamicUpdateTrait;
}

You can then update model attributes dynamically:

$model = User::find(1);
$model->updateName('Shah Sawood'); // name field will be updated 
$model->updateEmail('shahsawoodshinwari@gmail.com'); // email field will be updated

Additional Information

The package expects the fields to be updated are in snake_case.

Contributing

Contributions are welcome! Feel free to submit pull requests or open issues to improve the package.

License

The Dynamic Update Trait for Laravel is open-sourced software licensed under the MIT license.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2024-02-26