表单按钮
开发一个应用时,如果您希望重定向并且做一些其他操作时,不能使用简单的链接。GET 请求很容易受到 CSRF 攻击。
相反,您应该使用其他 HTTP 请求方式,使用表单和 CSRF 验证。 下面是一个在表单中生成按钮的 FormButton 组件。
{{-- content of formButton.blade.php --}} <form method="POST" action="{{ $action }}"> @csrf @method($method ?? 'POST') <button type="submit" class="{{ $class ?? '' }}" > {{ $slot }} </button> </form>
您可以像这样使用它:
// perform an action <x-form-button :action="route('doSomething')"> Do something </x-form-button> // perform an action with another HTTP verb <x-form-button :action="route('model.delete', $model)" method="delete"> Delete model </x-form-button>
导航栏
几乎任何应用程序都需要显示某种导航,比如菜单和选项卡。这些导航链接是动态的,这样用户就可以知道自己在应用程序的哪个部分。
下面是可以展示链接的 navigationLink 组件。当其以当前请求的 URL 开始时,它会自动将自身设置为活动状态。
{{-- content of navigationLink.blade.php --}} <li class="{{ \Illuminate\Support\Str::startsWith(request()->url(), $href) ? 'active' : '' }}"> <a href="{{ $href }}" @isset($dataDirtyWarn) data-dirty-warn @endisset> {{ $slot }} </a> </li>
这里是如何在 mailcoach.app 中使用它的。
<nav class="tabs"> <ul> <x-navigation-item :href="route('mailcoach.emailLists.subscribers', $emailList)"> <x-icon-label icon="fa-users" text="Subscribers" :count="$emailList->subscribers()->count() ?? 0" /> </x-navigation-item> <x-navigation-item :href="route('mailcoach.emailLists.tags', $emailList)"> <x-icon-label icon="fa-tag" text="Tags" /> </x-navigation-item> <x-navigation-item :href="route('mailcoach.emailLists.segments', $emailList)"> <x-icon-label icon="fa-chart-pie" text="Segments" /> </x-navigation-item> <x-navigation-item :href="route('mailcoach.emailLists.settings', $emailList)"> <x-icon-label icon="fa-cog" text="Settings" /> </x-navigation-item> </ul> </nav>
这就是渲染的方法。
表单元素
Blade 组件会渲染出自适应的表单元素。我们来看一下 textField 组件在 Mailcoach 中的用法。
<div class="form-row"> @if($label ?? null) <label class="{{ ($required ?? false) ? 'label label-required' : 'label' }}" for="{{ $name }}"> {{ $label }} </label> @endif @error($name) <p class="form-error" role="alert">{{ $message }}</p> @enderror <input autocomplete="off" type="{{ $type ?? 'text' }}" name="{{ $name }}" id="{{ $name }}" class="input" placeholder="{{ $placeholder ?? '' }}" value="{{ old($name, $value ?? '') }}" {{ ($required ?? false) ? 'required' : '' }} > </div>
正如你所看到的一样,它渲染了标签、表单字段和可能的错误。这就是它的用法。
<x-text-field label="Name" name="name" required />
以上是分享几个 Laravel 7 中很酷的 Blade 组件的详细内容。更多信息请关注PHP中文网其他相关文章!

Tocombatisolationandlonelinessinremotework,companiesshouldimplementregular,meaningfulinteractions,provideequalgrowthopportunities,andusetechnologyeffectively.1)Fostergenuineconnectionsthroughvirtualcoffeebreaksandpersonalsharing.2)Ensureremoteworkers

laravelispularfullull-stackDevelopmentBecapeitOffersAsAseAseAseAseBlendOfbackendEdpoperandPowerandForterFlexibility.1)ITSbackEndCapaPabilities,sightifyDatabaseInteractions.2)thebladeTemplatingEngingEngineAllolowsLows

选择视频会议平台的关键因素包括用户界面、安全性和功能。1)用户界面应直观,如Zoom。2)安全性需重视,MicrosoftTeams提供端到端加密。3)功能需匹配需求,GoogleMeet适合简短会议,CiscoWebex提供高级协作工具。

最新版本的Laravel10与MySQL5.7及以上、PostgreSQL9.6及以上、SQLite3.8.8及以上、SQLServer2017及以上兼容。这些版本选择是因为它们支持Laravel的ORM功能,如MySQL5.7的JSON数据类型,提升了查询和存储效率。

laravelisanexceltentchoiceforfull-stackdevelopmentduetoitsRobustFeaturesAndEsofuse.1)ITSImplifiesComplexComplextaskSwithitSmodernphpsyNtaxandToolSandToolSlikeBlikeforFront-Endandeloquentormquentormquentormforback-end.2)

Laravel10,releasedonFebruary7,2023,isthelatestversion.Itfeatures:1)Improvederrorhandlingwithanewreportmethodintheexceptionhandler,2)EnhancedsupportforPHP8.1featureslikeenums,and3)AnewLaravel\Promptspackageforinteractivecommand-lineprompts.

thelatestlaravelververversionenhancesdevelopmentwith:1)简化的inimpliticmodelbinding,2)增强EnhancedeloquentcapabibilitionswithNewqueryMethods和3)改善了supportorfortormodernphpfortornphpforternphpfeatureserslikenamedargenamedArgonedArgonsemandArgoctess,makecodingMoreftermeforefterMealiteFficeAndEnjoyaigaigaigaigaigaiganigaborabilyaboipaigyAndenjoyaigobyabory。

你可以在laravel.com/docs找到最新Laravel版本的发布说明。1)发布说明提供了新功能、错误修复和改进的详细信息。2)它们包含示例和解释,帮助理解新功能的应用。3)注意新功能的潜在复杂性和向后兼容性问题。4)定期审查发布说明可以保持更新并激发创新。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

SecLists
SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

mPDF
mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

SublimeText3 Linux新版
SublimeText3 Linux最新版

记事本++7.3.1
好用且免费的代码编辑器

DVWA
Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中