如果我编写一些带有弃用通知的 PHP 代码,它会显示在本地环境中。
示例:index.php
<?php
function super(string $test='', string $essai)
{
return 'toto';
}
super('sy', 1);
exit;
Run Code Online (Sandbox Code Playgroud)
显示:
Deprecated: Optional parameter $test declared before required parameter $essai is implicitly treated as a required parameter in /var/www/public/index.php on line 9
Run Code Online (Sandbox Code Playgroud)
这很好。
但是 Laravel 控制器中的完全相同的代码不会显示,并且不会存储在任何日志文件中。我将配置 app.env 设置为“local”,将 app.debug 设置为 true,将 app.log_level 设置为“debug”。知道我缺少什么吗?
我在 Laravel Blade 中有一个组件,想要class在不传递任何数据的情况下设置或内联样式。
我的简单代码是:
<x-atom.form class="mt-5" :data="$fields->main_form"></x-atom.form>
Run Code Online (Sandbox Code Playgroud)
mt-5未设置为x.atom.form组件
我的组件代码是:
<section class="contact-form"></section>
Run Code Online (Sandbox Code Playgroud) 我已经使用 npm 安装了@fortawesome/fontawesome-free软件包。最新的 Laravel 应用程序默认使用 vite。我无法解决这个问题。任何帮助将非常感激。我的vite.config.js是
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import { viteStaticCopy } from 'vite-plugin-static-copy';
export default defineConfig({
plugins: [
laravel([
'resources/css/app.css',
'resources/js/app.js',
'resources/admin/css/app.css',
'resources/admin/js/app.js',
'resources/css/glide.css',
'resources/js/glide.js',
'resources/js/Sortable.js',
'resources/js/tinymce.js',
'resources/sass/app.scss',
'resources/admin/sass/app.scss',
]),
{
name: 'blade',
handleHotUpdate({ file, server }) {
if (file.endsWith('.blade.php')) {
server.ws.send({
type: 'full-reload',
path: '*',
});
}
},
},
viteStaticCopy({
targets: [
{
src: 'node_modules/@fortawesome/fontawesome-free/webfonts',
dest: '',
},
],
}),
],
});
Run Code Online (Sandbox Code Playgroud)
我在app.scss中导入了 fontawesome scss …
作为一个例子,有这个组件:
资源/视图/组件/example.blade.php
<div>
@if($foo === "bar")
Bar
@else
Foo
@endif
</div>
Run Code Online (Sandbox Code Playgroud)
我渲染得像
@php
$foo = "bar";
@endphp
<x-example :foo="$foo" />
Run Code Online (Sandbox Code Playgroud)
什么在起作用。但是为了让我的代码看起来更干净,我想将字符串直接传递给组件,但我尝试的以下方法不起作用:
<x-example :foo="bar" />
<x-example :foo='bar' />
<x-example :foo="\'bar\'" />
<x-example :foo="'bar'" />
<x-example :foo=""bar"" />
Run Code Online (Sandbox Code Playgroud) 我在Laraval的Blade视图中有这段代码:
@foreach ($questions as $question)
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
@if(isset($question->task))
<a href="{{URL::action('showTask', $question->task_id)}}"><h4> <span class='glyphicon glyphicon-file'></span> {{$question->Task->name}}</h4></a>
@endif
<blockquote >
<a class="nostyle" href="{{URL::action('showQuestion',$question->id)}}" ><p
@if($question->status==1)
class="text-success"
@endif
>{{$question->text}}</p></a>
<footer>Gevraagd door <strong>{{$question->Author->getFullName('mij') }}</strong> op <strong>{{DateConverter::dateToString($question->created_at)}}</strong></footer>
@if($question->status==1)
<span class="label label-success">Beantwoord</span>
@endif
</blockquote>
</div>
@endforeach
Run Code Online (Sandbox Code Playgroud)
显示所有问题.我希望它们以3行的漂亮行显示.但是,有些文本($ question-> text)比其他文本更长,因此它们并不总是完美地开始新行,而是附加到最短的前一个网格,如屏幕截图所示.

我想要的更像是一张桌子,三列,然后是一个同一高度的新行,有三个新项目.
所以我正在寻找一种方法
或者在每三列之后自动添加和关闭行div.
最好的方法是什么?
我想实现Facebook分享按钮功能,它将在用户点击分享按钮期间捕获元标签信息.
我有一个head.blade.php,其中包含一些要捕获的元标记.例
<meta property="og:url" content="@yield('facebook_share_url')">
<meta property="og:image" content="@yield('facebook_share_image')">
<meta property="og:description" content="@yield('facebook_share_description')">
Run Code Online (Sandbox Code Playgroud)
我有一个default.blade.php.
<!doctype html>
<html>
<head>
@include('includes.head')
</head>
<body>
<div class="container">
<header class="row">
@include('includes.header')
</header>
<div id="main" class="row">
@yield('content')
</div>
</div>
@include('includes.footer')
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
因此,当我浏览一些网址www.example.com/details时,default.blade.php将从此details.blade中获取内容.此时我想更改facebook元标记属性,所以我在详细信息页面中执行了类似下面的操作.
@section('facebook_share_image', 'This is a description')
@section('facebook_share_description', 'This is an individual page title')
Run Code Online (Sandbox Code Playgroud)
代码工作正常,但我想从我的视图数据中呈现它.就像是@section('facebook_share_description', {{ $data->description }})
但是当我检查我的元标记时,它什么也没给我.有可能这样做吗?
我有一个表通过laravel php显示数字.这些数字基于一周的时间段,并且与每天相关联的值在刷新时相应地更新.现在我需要在flot图表中获取这些数据.典型的flot图表将具有如下静态点:
var data = [[0, 0], [1, 10], [2,5], [3, 12], [4, 9], [5, 4], [6, 2]];
Run Code Online (Sandbox Code Playgroud)
但我需要每个点都是动态的:
@foreach($days as $day)
var data = [[{{ $day['carbon']->format('F j, Y') }},{{ $day['total'] }}]]
@endforeach
Run Code Online (Sandbox Code Playgroud)
当然,这打破了图表,但它不起作用.我有点被困在这里.任何建议将不胜感激.
如果网站访问/页面的用户,我希望他重定向到索引与消息.如何在视图中访问重定向消息?我的路线:
Route::group(['middleware' => 'web'],function(){
Route::get('/page', function () {
return redirect('/')->withMessage(["warning"=> ["yeah","test"]]); // According official docs, this should work.
});
Route::get('/', 'Page@front');
});
Run Code Online (Sandbox Code Playgroud)
我的页面控制器:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\News;
use App\PageContact;
use Session;
class Page extends Controller{
public function front(Request $Request){
return view('index')->withNews("news");
}
Run Code Online (Sandbox Code Playgroud)
重要的是:是的,我的网页已经包含在网络中间件中.请避免发布Laravel 3或Laravel 4解决方案.
我试图用Laravel 5.3与视图页面(刀片)建立动态链接.
我的方法是:
<a href=" {{ URL::to('articles') }}/{{ $article->id}}/edit">Edit></a>
Run Code Online (Sandbox Code Playgroud)
这将输出正确的网址与我的基本网址和其他一些slug: http://mydomain/articles/23/edit
其中"23"是我的文章的ID.
这有效,但我想知道是否有更清洁的方法呢?
非常感谢
如果我dd($items);在控制器中,结果如下:
在视图刀片laravel我检查集合是否为空如下:
@if($items)
...
@endif
Run Code Online (Sandbox Code Playgroud)
但它不起作用
我怎么解决这个问题?
laravel-blade ×10
laravel ×8
php ×5
css ×2
laravel-5.2 ×2
blade ×1
collections ×1
debugging ×1
flot ×1
font-awesome ×1
grid ×1
html ×1
if-statement ×1
javascript ×1
laravel-5.6 ×1
log-level ×1
logging ×1
redirect ×1
vite ×1
vue.js ×1