定制 wibesoft-company/laravel-request-default 二次开发

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

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

wibesoft-company/laravel-request-default

最新稳定版本:v1.0.1

Composer 安装命令:

composer require wibesoft-company/laravel-request-default

包简介

A Laravel library to set default values for request parameters.

README 文档

README

Introduction

LaravelRequestDefault is a Laravel library designed to enhance Laravel Requests by allowing developers to set default values for request parameters. This library is particularly useful in scenarios where certain request parameters may not be provided but are needed for the application logic to function correctly. It seamlessly integrates with Laravel's existing request validation system, making it a convenient addition to any Laravel project.

Features

  • Default Value Setting: Easily set default values for any request parameters.
  • Seamless Integration: Works coherently with Laravel's validation and request handling.
  • Flexible Configuration: Define defaults for various request types within your application.

Installation

To install LaravelRequestDefault, you need to require the package via Composer. Run the following command in your terminal:

composer require wibesoft-company/laravel-request-default

Usage

Basic Usage

After installing the package, use the InputDefaulter trait in your form request classes. Here's an example:

<?php

namespace App\Http\Requests\BotMatch;

use Illuminate\Foundation\Http\FormRequest;
use WibesoftCompany\LaravelRequestDefault\Traits\InputDefaulter;

class FilterRequest extends FormRequest
{
    use InputDefaulter;

    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'page' => 'numeric',
            'per_page' => 'numeric',
            'from_date' => 'date',
            'to_date' => 'required|date|date_equals:to_date',
        ];
    }

    public function defaults(): array
    {
        return [
            'page' => 1,
            'per_page' => 10,
            'from_date' => now()->subDays(10)
        ];
    }
}

Defining Defaults

Define your default values in the defaults method of your form request. The defaults method should return an associative array where the keys are the request parameters and the values are their respective defaults.

License

LaravelRequestDefault is open-sourced software licensed under the MIT license.

For more information, please visit the project homepage.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固