承接 ngoubaux/delatbabel-fluents 相关项目开发

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

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

ngoubaux/delatbabel-fluents

最新稳定版本:v11.0

Composer 安装命令:

composer require ngoubaux/delatbabel-fluents

包简介

Convert Eloquent Model objects to and from Fluent objects.

README 文档

README

Laravel extension to convert to/from Fluent objects.

Rationale

The Laravel Fluent object is one of the most under-rated and under-utilized components of the framework. Essentially a free-standing object, it allows you to access an array of attributes as an object rather than as an array.

example:

Instead of using an array like this:

$myArray = [];
$myArray['first'] = 'one';
$myArray['second'] = 'two;

echo $myArray['first']; // prints "one"

Use fluent object like this:

$myObject = new Fluent();
$myObject->first = 'one';
$myObject->second = 'two';

echo $myObject->first; // prints "one"

Until now, however, there has been no standard straightforwards way to convert an Eloquent Model object into a Fluent object. There is a toArray() function on a Model object but no equivalent toFluent() function.

This component adds such functions using a trait that can be applied to any model object. Note that several other of Laravel's internal classes can also have this trait applied, as long as they store their data in an internal attributes array this trait should work.

Usage

Model Fill From Fluent Object

use Delatbabel\Fluents\Fluents;

class User extends Eloquent {
    use Fluents;
}

$myFluent = new Fluent();
$myFluent->first = 'one';

$myUser = new User();
$myUser->fromFluent($myFluent);

Model Convert From Fluent Object

use Delatbabel\Fluents\Fluents;

class User extends Eloquent {
    use Fluents;
}

$myUser = User->find(1);
$myFluent = User->toFluent();

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固