定制 janchris80/laravel-macros 二次开发

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

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

janchris80/laravel-macros

Composer 安装命令:

composer require janchris80/laravel-macros

包简介

Reusable laravel macros.

README 文档

README

Reusable laravel macros.

Test Response Macros

dd

Helpful for inspecting the response and output of your controllers during phpunit testing.

$response = $this->post(...);

$response
    ->dd() // prints the json response or the error response if any.
    ->assertOk()
    ->assertJson(...);

ddO

Similar to $response->dd() but it dump the original content instead.

$response = $this->post(...);

$response
    ->ddO() // prints the original content of the response.
    ->assertOk()
    ->assertJson(...);

Query Builder Macros

toRawSql

Return the mysql raw query. Include the parsed sql bindings. Also available to eloquent model.

DB::table('users')->whereRaw('active = ?', [1])->toRawSql(); // select * from users where active = 1
User::whereRaw('active = ?', [1])->toRawSql(); // select * from users where active = 1

dd

Dd the raw sql. Helpful for debugging in between query method calls. Enabled in local and testing environments only because you don't want to dd your queries and let other people see it.

User::where('active', 1)
    ->dd() // dd here will print "select * from users where active = 1"
    ->whereNotNull('email')
    ->dd() // dd here will print "select * from users where active = 1 and email is not null"
    ->get();

log

For logging mysql queries.

User::where('active', 1)
    ->whereNotNull('email')
    ->log() // will log "select * from users where active = 1 and email is not null"
    ->get();

Request Macros

bool

Cast input to boolean.

$request->input('keep_me_logged_in'); // "false"
$request->bool('keep_me_logged_in'); // false

int

Cast input to integer.

$request->input('quantity'); // "1,000"
$request->int('quantity'); // 1000

float

Cast input to float.

$request->input('price'); // "1,000.50"
$request->float('price'); // 1000.50

Merging the casted input into the request permanently.

$request->merge($request->float(['price', 'cost', 'vat', 'discount']));

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-05-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固