我正在努力在 Laravel 的刀片模板中创建链接。我将从环境变量中传递模板中的 URL。
输出应该是这样的。
<a href="https://google.com">Visit Google</a>Run Code Online (Sandbox Code Playgroud)
我正在尝试这样的事情,但没有运气。
<a href="{{env('APP_URL')}}">Visit my site</a>Run Code Online (Sandbox Code Playgroud)
Laravel 框架 5.5.19
谢谢
缺少 [路由:verification.notice] [URI:{语言}/email/verify] 所需的参数
使用本地化后,我将 laravel 电子邮件验证添加到我的项目中。但现在我遇到了 Route:verification.notice 缺少参数的问题。我知道我需要将 app()->getLocale() 参数添加/传递到路线,但找不到位置
我尝试搜索项目中的所有路由和 URL,并检查了 VerificationController.php 和 verify.blade.php。但我没有找到缺少参数的路线。另外,我在网上找不到有同样问题的人。
网页.php
Route::group([
'prefix' => '{language}',
'where' => ['{language}' => '[a-Za-Z]{2}'],
'middleware' => 'SetLanguage',
],
function () {
Route::get('/', function () {
return view('welcome');
})->name('Welcome');
Auth::routes(['verify' => true]);
Route::get('/home', 'HomeController@index')->name('home');
Route::namespace('User')->group(function () {
Route::get('/profile', 'UserController@editProfile')->name('profile');
Route::put('profile', 'UserController@updateProfile');
});
Route::namespace('Admin')->group(function () {
Route::get('/dashboard', 'AdminController@index')->name('dashboard');
});
});
Run Code Online (Sandbox Code Playgroud)
用户控制器
class UserController extends Controller
{
public function __construct()
{
$this->middleware('verified');
}
public function editProfile()
{
$user = User::where('id', Auth()->user()->id)->first(); …Run Code Online (Sandbox Code Playgroud) laravel-localization laravel-blade laravel-authentication laravel-6
我有一个 Laravel 7 组件,如下所示
class Input extends Component
{
public $name;
public $title;
public $value;
public $type = 'text';
/**
* Create a new component instance.
*
* @return void
*/
public function __construct($name, $title)
{
$this->name = $name;
$this->title = $title;
$this->value = \Form::getValueAttribute($name);
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\View\View|string
*/
public function render()
{
return view('components.fields.input');
}
}
Run Code Online (Sandbox Code Playgroud)
我可以像这样在 Blade 组件中渲染该字段:
<x-input name="name" :title="__('My field')" />
我需要在代码中创建和渲染该字段,我尝试了以下操作:
$field …Run Code Online (Sandbox Code Playgroud) 我知道 Laravel 中的命名约定包含在另一个问题中,但刀片文件没有在那里介绍。我阅读了几个博客和论坛,它们都提供了不同的方法,所以我想在这里问:
我的控制器方法是AdminController@listPropertyTypes - 它列出和管理属性类型..
一篇博客建议:
/resources/views/admin/property/types.blade.php
Run Code Online (Sandbox Code Playgroud)
另一个博客建议下划线或没有空格:
/resources/views/admin/property_types.blade.php
/resources/views/admin/propertytypes.blade.php
Run Code Online (Sandbox Code Playgroud)
我个人会这样命名,因为它是一个视图:
/resources/views/admin/property-types.blade.php
Run Code Online (Sandbox Code Playgroud)
是否有最佳实践或 PSR 规则?
我在本地的 Mac 上开发。大苏尔的最新版本。
今天,我通过 Forge 通过 Ubuntu 服务器将我的应用程序部署到生产环境中,但遇到了一个我以前从未见过的错误,并且无法在网上找到答案。我可以看到很多人在抱怨它,但是任何人在其他答案中所说的都是指向没有解决方案甚至没有解释的问题的链接,所以这就是我提出一个新问题的原因。
确切的错误是这样的;
Unable to locate a class or view for component [layouts.base]. (View: /home/forge/default/releases/20201204084441/resources/views/layouts/app.blade.php)
在我的应用程序中,我有;
app\View\Components\Layouts\App.php
看起来像这样;
<?php
namespace App\View\Components\Layouts;
use Illuminate\View\Component;
class App extends Component
{
public function render()
{
return view('layouts.app');
}
}
Run Code Online (Sandbox Code Playgroud)
那我也有;
resources\views\layouts\app.blade.php
<x-layouts.base>
<!-- contents -->
</x-layouts.base>
Run Code Online (Sandbox Code Playgroud)
(也几乎相同的基础)
在 Mac 上完美运行。一旦我在 Ubuntu 上部署它,我就会收到上面的错误,即“无法找到具有这些名称的类或视图”。
有人可以指导我如何解决这个问题,因为到目前为止我完全不知道,尽管知道区分大小写可能是其他问题的问题,但我找不到任何实际的解决方案或方法来解决这个。
我的代码是这样的:
<multiple-photo-product :product="{{ isset($product) ? $product : '' }}"></multiple-photo-product>
Run Code Online (Sandbox Code Playgroud)
代码运行时会引发错误:
语法错误:出现意外的标记}
但是,如果代码是这样的:
<multiple-photo-product product="{{ isset($product) ? $product : '' }}"></multiple-photo-product>
Run Code Online (Sandbox Code Playgroud)
它不会引发错误。
我添加:,以便将数据作为对象发送。
如果不使用:,则数据以字符串形式发送。
我该如何解决?
使用 Laravel 5.5.34,我在使用 dump() 帮助程序在 Blade 模板中输出调试信息时遇到问题。
{{ dump('test') }}
Run Code Online (Sandbox Code Playgroud)
产生以下输出:
我不希望原始字符串“test”出现在实际调试输出下方。这是正常行为吗?如果是,我该如何禁用它?如果不是,什么错误配置可能导致它?
我正在使用Laravel 5.6。此页面不适用于我。
pizza / index.blade.php看起来像这样:
@extends('layouts.app')
@section('content')
<!-- Styles -->
<link href="{{ asset('css/pizza.css') }}" rel="stylesheet">
<!-- Scripts -->
<script src="{{ asset('js/components/pizza.js')}}"></script>
<div class="container">
<div class="row justify-content-center">
<div class="card">
<div class="card-header">Pizza</div>
<div class="card-body">
<form action="/pizzas" method="post">
@if ($errors->any())
<div class="alert alert-danger" role="alert">
Please fix the following errors
</div>
@endif
@include('pizza.table')
</form>
</div>
</div>
</div>
</div>
@endsection
Run Code Online (Sandbox Code Playgroud)
披萨/table.blade.php:
<div class="pizza-selection">
<b>Thanks god its pizza day! Select your pizza of the day!</b>
<table id="pizzas" class="md-box">
<tr>
...
</tr>
@foreach ($pizzas as …Run Code Online (Sandbox Code Playgroud) 我有一个输出 $slot 的组件。但我想做一些类似的事情:
成分
<x-alert></x-alert>
Run Code Online (Sandbox Code Playgroud)
<div>
@if ($slot)
{{ $slot }}
@else
No available content
@endif
</div>
Run Code Online (Sandbox Code Playgroud) laravel-blade ×10
laravel ×6
laravel-5 ×3
php ×3
dump ×1
echo ×1
javascript ×1
laravel-6 ×1
laravel-7 ×1
multilingual ×1
vue.js ×1
vuejs2 ×1