承接 rdx/laravel-link-url 相关项目开发

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

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

rdx/laravel-link-url

最新稳定版本:2.6

Composer 安装命令:

composer require rdx/laravel-link-url

包简介

Mutable Laravel links & urls

README 文档

README

What?

Normal Laravel links, urls and redirects aren't mutable, because they're ready strings. You make them and that's it. You can't add query params after, and you can't add a #fragment at all.

This makes for unreadable links/urls:

$link = link_to_route('users.show', 'Some label here', ['user' => 321, 'report' => 123], ['title' => 'The title of the link', 'id' => "link-{$user->id}"]);

Which part is a URL component, and which part a custom query param, and which part an HTML attribute..?

How?

Add the service provider (happens automatically):

rdx\linkurl\LinkUrlServiceProvider::class

Make sure laravelcollective/html is installed. It makes links.

Links, urls and redirects are mutable objects now:

// Link: <a href="/users/123?report=14#table-reports">View users</a>
echo linkurl_to_route('users.show', 'View user', [$user])->query('report', 14)->fragment('table-reports');

// Link: <a href="/reports/123/delete?_token=huy6543gy654" class="delete">x</a>
echo linkurl_to_route('reports.delete', 'x', [$report])->add('class', 'delete')->withCsrf();

// Url: https://example.com/users/123/edit?return=https%3A%2F%2Fexample.com%2Fusers
$url = routeurl('users.edit', [$user])->query('return', route('users.index'));

// Redirect: /users/123#table-reports
return redirect()->route('users.show', [$user])->fragment('table-reports');

Links and Urls are built in __toString() at the last moment.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-12-26