blade

Laravel 从入门到精通系列教程

微笑、不失礼 提交于 2020-04-28 04:34:18
转载;https://laravelacademy.org/laravel-tutorial-5_7 适用于 Laravel 5.5、5.6、5.7 版本,本系列教程将围绕一个 LTS 版本,然后采取增量更新方式,随着 Laravel 版本的升级不断进行更新,直到 Laravel 框架不再维护。比如这个教程是在 Laravel 5.5 教程的基础上,涵盖 5.6、5.7 版本的功能。 有人会问这个教程和官方文档有什么区别, 文档相对晦涩, 很多地方会让新手云里雾里, 且各章节相互独立、松散,你可以将本系列教程看作一本针对 Laravel 的、开放式的、持续更新的、以实例驱动的、深入浅出的非官方实战指南。 本系列教程源码存放在 Github 上: https://github.com/nonfu/laravel-tutorial-code 更新频率:为保证教程质量,每周一、三、五更新。 一、预备篇 PHP 知识储备 Composer 命名空间 Trait 闭包和匿名函数 搭建开发环境 基于 Vagrant + Virtual Box 构建本地开发环境:Homestead(适用于全平台) (Windows 平台安装还可以参考 这篇教程 ) 基于 Docker 构建本地开发环境:Laradock(适用于全平台) 适用于 Mac 的轻量级开发环境:Laravel Valet 适用于

Laravel localization to German and special letters

折月煮酒 提交于 2020-04-17 15:14:24
问题 I have a problem with some German's special letters (ö, ü...) in my Laravel application. My encoding is set to UTF-8. Everything works fine with the content from the database (where is utf8_general_ci ). When I hardcode some text to Blade view files, that's fine, too. But, I'm using localization files ( /app/lang/de/myFile.php ) with an associative array. German characters from that array are displayed as � � �. What is strange, when I var_dump(trans('myFile.key')) in Blade, special

Laravel localization to German and special letters

北城以北 提交于 2020-04-17 15:12:45
问题 I have a problem with some German's special letters (ö, ü...) in my Laravel application. My encoding is set to UTF-8. Everything works fine with the content from the database (where is utf8_general_ci ). When I hardcode some text to Blade view files, that's fine, too. But, I'm using localization files ( /app/lang/de/myFile.php ) with an associative array. German characters from that array are displayed as � � �. What is strange, when I var_dump(trans('myFile.key')) in Blade, special

Laravel 7.5 发布

跟風遠走 提交于 2020-04-17 10:47:54
【推荐阅读】微服务还能火多久?>>> Laravel 团队昨天发布了 v7.5.0,其中包含了框架的一些更新的最新功能、修复和优化: 新的 Http 客户端断言 Christoph Rumpel 为 Http 客户端提供了两个新的测试方法: Http::assertNotSent(function ($request) { return $request->hasHeader('X-First', 'foo') && $request->url() == 'http://test.com/users' && $request['name'] == 'Taylor' && $request['role'] == 'Developer'; }); Http::assertNothingSent(); assertNotSent() 应该返回一个 boolean 值条件,并带有你需要匹配请求的约束条件。这些方法补充了现有的 assertSent() 方法,在代码应导致不发送特定请求或不发送请求的情况下提供相反情况的检查。 重命名字段添加枚举支持 根据此功能的 PR “在迁移中,无法在带有枚举列的表中通过 renameColumn () 或 change () 方法重命名或修改列类型。” 如果我正确理解 PR 的话,你可以在枚举列上面调用 change() 方法: 更新: PR 作者澄清了

【笔记】《Bootstrap实战》——第3章 WordPress主题【自】

做~自己de王妃 提交于 2020-04-15 17:26:52
【推荐阅读】微服务还能火多久?>>> 文章目录 一、导航部分 1.引入 bootstrap 和 jquery 2.添加导航 二、添加首页内容 1.上传并处理图片 2.添加首页内容 三、自定义页面模板 四、理解Roots的基准模板 五、创建自定义的基本模板 六、在自定义结构中使用自定义栏目 七、创建自定义的内容模板 八、通过自定义栏目构建传送带 九、加入页脚内容 十、更换我们的assets资源 wordpress主题添加资源文件(js、css)还是不熟悉 一、导航部分 1.引入 bootstrap 和 jquery 修改以下文件 \resources\views\partials\head.blade.php : 原文件: <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> @php wp_head() @endphp </head> 修改为: <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie

laravel access to model constant in blade

喜你入骨 提交于 2020-04-13 07:22:08
问题 Need access model constant in blade not with full path class PaymentMethod extends Model { const PAYPAL_ACCOUNT = 'paypal_account'; const CREDIT_CARD = 'credit_card'; and in blade {{ App\Classes\Models\PaymentMethod::CREDIT_CARD }} work but {{ PaymentMethod::CREDIT_CARD }} throws Class 'PaymentMethod' not found 回答1: You may use aliases: in your config\app.php under aliases section : aliases => [ .... 'PaymentMethod' => App\Classes\Models\PaymentMethod::class ] then use it in your balde file {

2020年九大Java开发框架都有什么?

早过忘川 提交于 2020-04-10 09:41:22
2020年九大java开发框架,小编主要介绍Spring框架、Hibernate框架、Struts框架、Play框架、GoogleWebToolkit框架、Grails框架、Blade框架、JavaServerFaces框架、Vaadin框架九大框架,希望您可以多java框架有更多的认识。 一、Spring框架   Spring框架框架排名首位,具有开发复杂Web应用程序的出色能力,这些应用程序因性能突出而广受赞誉。使Java开发人员能够轻松地创建企业级应用程序。Web应用程序开发人员可以证明Spring框架的能力。是Spring成为Java开发人员最爱的原因。 在开发人员的选择中,SpringMVC和SpringBoot远远领先于其他Java技术。对于开发人员来说,这里的一大优势是他们可以不受其他模块约束而专注于一个模块,因为Spring利用了控制反转(IoC)。其他优点是一个全面的配置模型,支持传统数据库和现代数据库(如NoSQL),并通过支持面向方面编程来支持内聚开发。提供一些模块如SpringMVC、SpringCore、SpringBoot、SpringTransaction等。 二、Hibernate框架   作为一个对象关系映射(ORM)数据库,改变了我们以前查看数据库的方式。尽管不是一个全栈框架,但可以极其轻松地为多个数据库转换数据。支持多个数据库的能力使很容易扩展

laravel withInput() 和old()

ぐ巨炮叔叔 提交于 2020-02-26 05:41:34
传统提交表单 页面会刷新,输入框里的内容会丢失掉。 更好的用户体验 解决办法withInput() + old() laravel 会自动把用户输入的数据存到一次性的session里。 使用old()可以将上次提交的数据从一次性session里取出来,挂在DOM元素上,从而避免用户重新输入。 使用withInput(),配合with方法,可以将想要返回的参数写入session中。blade模板便可以从session中取出值,来做一些逻辑判断。 return redirect()-> back()->withInput()->with(['error'=>'注册失败,短信验证码不正确','page'=>'phone']); 1 blade模板old()赋值函数写法 <input type="text" name="username" value="{{ old('username') }}"> 来源: oschina 链接: https://my.oschina.net/u/3371661/blog/3168748

Translate to Blade+Laravel a while loop

巧了我就是萌 提交于 2020-02-16 07:35:00
问题 This code works, however in my learning of Laravel, I want to know if using Blade+Laravel syntax, can be better implemented <?php $i = 1; while ($i <= (5 - $post->images->count())) { echo '<div class="col"> </div>'; $i++; } ?> Thanks 回答1: https://laravel.com/docs/5.5/blade#loops I would suggest using a for loop instead of a while loop in this case: @for ($i = 1; $i <= (5 - $post->images->count()); $i++) <div class="col"> </div> @endfor 回答2: I'm not sure is the best way to do, but works. <?php

Laravel Blade without extra whitespace?

谁说我不能喝 提交于 2020-01-29 06:49:48
问题 If you do this you get an error: <p>@if($foo)@if($bar)test@endif@endif</p> And if you do this, you get <p> test </p> , adding too much whitepace: <p>@if($foo) @if($bar)test@endif @endif</p> Is there a way to avoid this? Edit: see my answer below for an updated response. There's a clean way to do this with no hacks or external libraries. 回答1: Try with a ternary operator, there is no whitespace control in Laravel <p>{{ $foo ? ($bar ? 'test' : '') : ''}}</p> 回答2: You could always use the