我想将 url 数据放入我的输入值中。
例子:
- 网址是http://example.com/user?username=example
- 我的html输入代码如下
<input value="{{ request()->input('username') or old('username') }}">- 但结果总是返回“1”而不是“示例”
似乎“或”刀片助手充当条件运算符。
如何从 url 获取用户名值到该输入中并仍然获得默认值作为 old('username')?
我已经将我的 Laravel 应用程序部署到我的VPS 中。它在本地主机上运行良好。我认为错误出在我的路由或控制器中,因为路径仍在我的本地机器目录中(请参阅错误消息第 2 行),但我真的看不到代码中的问题。
我试过使用php artisan config:cache, php artisan cache:clear,php artisan route:cache但它仍然不起作用。它仍然是指我的本地机器目录。
这是 index.blade.php 的目录
Root
|-- portofolio
|-- app
|-- bootstrap
|-- config
|-- database
|-- resources
|-- assets
|-- lang
|-- views
|-- index.blade.php
|-- routes
|-- storage
|-- tests
|-- vendor
|-- public_html
|-- css
|-- img
|-- js
|-- vendor
Run Code Online (Sandbox Code Playgroud)
这是路线
Route::get('/', ['as' => 'home', 'uses' => 'Portofolio@link']);
Run Code Online (Sandbox Code Playgroud)
这是控制器
<?php
namespace …Run Code Online (Sandbox Code Playgroud) 我使用 Laravel 5.3,我使用 Laravel 的默认模板(刀片)来布局和处理我的页面。在这里我不能使用@push来包含我的脚本,但我可以使用@include来正常工作。
这两个实现有什么问题?
为什么它不支持@push,但相同的脚本与@include 一起工作正常
我的代码:
@section('scripts')
// My Scripts //
@show
Run Code Online (Sandbox Code Playgroud)
访问时,
@push('scripts')
// My New Scripts //
@endpush
Run Code Online (Sandbox Code Playgroud)
这对我不起作用。
但是,如果我尝试@include,
@include('partials.scripts')
Run Code Online (Sandbox Code Playgroud)
它完美地工作!
这有什么问题?
有什么解决办法吗?
谢谢 !
我正在使用Laravel Collective for Forms 并遇到复选框问题。
这是我在做什么:
{!! Form::checkbox('independent',null,['class'=>'form-control', 'required' => 'required'])!!}
Run Code Online (Sandbox Code Playgroud)
我尝试更改“null”的值,在谷歌搜索解决方案时添加了许多建议的参数,但似乎没有任何效果。
如果有人知道解决方案或有同样的问题,请分享。
我正在将一个数组从我的控制器传递给一个视图。
这是控制器功能:
$notification = array(
'message' => 'Welcome Admin!',
'alert_type' => 'success',
);
return redirect('/home')->with('notification', $notification);
Run Code Online (Sandbox Code Playgroud)
在我看来:
<script>
@if(Session::has('notification'))//this line works as expected
var type = "{{ Session::get('alert_type', 'info') }}";
//but the type var gets assigned with default value(info)
switch(type){
case 'info':
toastr.info("{{ Session::get('message') }}");
break;
case 'warning':
toastr.warning("{{ Session::get('message') }}");
break;
case 'success':
toastr.success("{{ Session::get('message') }}");
break;
case 'error':
toastr.error("{{ Session::get('message') }}");
break;
}
@endif
</script>
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我试图访问数组值的方式显然有问题 var type = "{{ Session::get('alert_type', 'info') }}";
编辑- 1:我试过做
var type …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用刀片语法在我的用户页面中包含文件
@include('header')
@yield('content')
@include('footer')
Run Code Online (Sandbox Code Playgroud)

这是 web.php
Route::get('/', function () {
return view('layouts.user');
});
Run Code Online (Sandbox Code Playgroud)
我收到这个错误
(1/1) InvalidArgumentException 查看 [layouts.user] 未找到。
我想在刀片中连接 javascript 变量{{ curly braces }},如下所示:
目前:
ajax: "{{ route(api.colors) }},"
我想要的是:
var page='colors';
...
ajax: "{{ route(api."+page+") }},"
Run Code Online (Sandbox Code Playgroud)
是否可以?
我想将我看到的日期的语言从英语更改为法语
{{ strftime("%d %B %Y, %H:%M", strtotime($article->created_at)) }}
Run Code Online (Sandbox Code Playgroud) 我很好奇如何在多语言应用程序中有效地生成电子邮件。
为了使所有答案一致:假设您有一个典型的商业通讯,其中包含大量图像、标记,当然还有许多文本段落。假设所有文本都不是来自数据库,而是应该是硬编码的。此外,这些段落中的某些词可以加粗、强调、... 时事通讯将在订阅者的首选语言环境中发送。
我怎样才能建立一个系统来处理这个问题?
trans()在 Laravel 的lang文件夹中引用每个段落并定义所有翻译吗?那么单词标记部分呢?在语言文件中加入 HTML 标签对我来说感觉有些不对。@foreach ($searchalls as $searchall)
@php
$i=1
@endphp
{{$i }} ={{$loop->iteration}}%3
@if($i == 1 )
<div class="row clearfix">
@endif
<div class="col-md-4 column">
<h2>
{{$search_all->id }}Heading
</h2><p>once OK.
</p>
<p>
<a class="btn" href="#">View details »</a>
</p>
</div>
Run Code Online (Sandbox Code Playgroud)
我在刀片上得到的结果是
1 =1%3
1 =2%3
1 =3%3
1 =4%3
Run Code Online (Sandbox Code Playgroud)
不能得到数字余数?
我该如何解决这个问题?
laravel-blade ×10
laravel ×9
php ×6
laravel-5.4 ×3
blade ×2
javascript ×2
arrays ×1
checkbox ×1
deployment ×1
email ×1
laravel-5.5 ×1
php-carbon ×1
reminders ×1
routes ×1