1.0.0 2024-09-29 06:34 UTC

This package is auto-updated.

Last update: 2024-11-29 07:08:29 UTC


README

composer require guanhui07/dto dev-main

定义dto类

namespace App\Services\Entity;
use Guanhui07\BaseDto;

class MsgGiftDto extends BaseDto
{

    /**
     * 礼物ID
     * @var int
     */
    public $id;

    /**
     * 礼物数量
     * @var int
     */
    public $number;
    
   /**
     * 礼物名
     * @var int
     */
    public $gift_name;

}

使用dto 传参 方式1

$giftDto = new MsgGiftDto([
    'id' => 1,
    'number' => 10,
    'gift_name' => 'test123',
])

$obj->send($giftDto);

使用dto 传参 方式2

$giftDto = new MsgGiftDto()->fill([
    'id' => 1,
    'number' => 10,
    'gift_name' => 'test123',
]);

$obj->send($giftDto);

使用dto 传参 方式3

$giftDto = new MsgGiftDto();
$giftDto->id = 1;
$giftDto->number = 10;
$giftDto->gift_name = 'test123';

$obj->send($giftDto);