在Laravel 4中,我能够使用...获取当前路线名称
Route::currentRouteName()
Run Code Online (Sandbox Code Playgroud)
我怎么能在Laravel 5中做到这一点?
迁移我的数据库时出现此错误,下面是我的代码,后面是我在尝试运行迁移时遇到的错误.
码
public function up()
{
Schema::create('meals', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned();
$table->integer('category_id')->unsigned();
$table->string('title');
$table->string('body');
$table->string('meal_av');
$table->timestamps();
$table->foreign('user_id')
->references('id')
->on('users')
->onDelete('cascade');
$table->foreign('category_id')
->references('id')
->on('categories')
->onDelete('cascade');
});
}
Run Code Online (Sandbox Code Playgroud)
错误信息
[Illuminate\Database\QueryException]
SQLSTATE[HY000]: General error: 1005 Can't create table `meal`.`#sql-11d2_1
4` (errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter
table `meals` add constraint meals_category_id_foreign foreign key (`catego
ry_id`) references `categories` (`id`) on delete cascade)
Run Code Online (Sandbox Code Playgroud) 我是laravel的初学者。我已经创建了项目。我已经对它运行了以下命令。
composer require laravel/ui --dev
npm install
npm run dev
php artisan ui vue
php artisan ui vue --auth
Run Code Online (Sandbox Code Playgroud)
此命令后,我得到Login
和Register
我的欢迎页面上的菜单。现在我的 Laravel 欢迎页面可以正确加载。但是当我点击登录时,它显示的是纯 html。我搜索并检查了 app.blade.php 中的 css 和 js 链接。看起来不错。layouts/app.blade.php 具有以下链接
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
<script src="{{ asset('js/app.js') }}" defer></script>
Run Code Online (Sandbox Code Playgroud)
问题应该出在哪里?当欢迎页面获取 css 时,为什么登录和注册没有获取 css?请指导。
所以我的 Mailable 视图抛出了这个错误——这就是我手头上的一切。当我使用 Lumen 5.8 时它运行良好,所以我猜测它是在升级到 Laravel 6 之后发生的。
调用未定义的函数array_except()(查看:/kunden/182801_60322/tu/uat/api/resources/views/mail/invite-employee.blade.php)
我的刀片文件如下所示:
@extends('mail.master')
@section('content')
<tr>
<td align="left" style="border: 1px solid #dddee5; border-bottom: 2px solid #cecfd9; padding; 20px;">
<div class="padded">
<p>
{!! nl2br(e($data->message)) !!}
</p>
</div>
</td>
<tr>
<tr>
<td align="left" bgcolor="#eaeaf2" class="padded">
<p style="margin-bottom: 5px;" class="cta-label">{{ $data->copy->click }}</p>
<div class="cta-link">
<a style="color: #337BE9;" class="cta-link--a" href="{{ $data->appUrl }}/{{ $data->route }}/{{ $data->verificationCode }}">{{ $data->appUrl }}/{{ $data->route }}/{{ $data->verificationCode }}</a>
</div>
<p style="font-size: 12px; margin-top: 10px;">{{ $data->copy->mistake }}</p>
</td>
</tr>
@endsection
Run Code Online (Sandbox Code Playgroud)
显然代码的任何部分都没有试图调用该函数。
我的 composer.json …
我在 laravel 中开始了一个新项目,但我的作曲家安装了一个新版本的 laravel 6.0.1。
Php artisan make:auth
命令无法工作。
我尝试了很多次但错误无法删除
composer require laravel/ui
Run Code Online (Sandbox Code Playgroud)
安装但是当我使用第二个命令时:
php artisan ui vue --auth
Run Code Online (Sandbox Code Playgroud)
然后系统向我显示此消息:
Command "ui" is not defined.
Using version ^1.0 for laravel/ui
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
PHP Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 4096 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/RuleSetGenerator.php on line 129
Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 4096 bytes) in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/DependencyResolver/RuleSetGenerator.php …
Run Code Online (Sandbox Code Playgroud) 我已经将laravel 5.8项目升级到6.0。它已成功升级,但是当我尝试运行该项目或将另一个软件包安装到我的项目时,它给我的错误称为session.php中的“调用未定义的函数str_slug()”。我不知道为什么。
Call to undefined function str_slug()
我的 Vue 后端使用 Laravel 6 护照授权密码。
当我向oauth/token发送正确的凭据时,它会工作并返回令牌,但是当我发送错误的(电子邮件/密码)时,它会返回 400 而不是 401 与此消息。
{
"error": "invalid_grant",
"error_description": "The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.",
"hint": "",
"message": "The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used …
Run Code Online (Sandbox Code Playgroud) 将 laravel 5.8 升级到 laravel 6.x 后,我收到此错误:
Undefined class constant 'App\Providers\RouteServiceProvider::HOME'
Run Code Online (Sandbox Code Playgroud)
升级之前的应用登录系统是自定义的。升级到 laravel 6.x 后,我想使用 laravel 默认身份验证。我通过创建的认证php artisan ui:auth
,我复制从新鲜laravel控制器app/Http/Controllers/Auth
文件夹与身份验证有关的控制器一样- LoginController
,RegisterController
等等。
我应该怎么做才能解决上述错误?请有人帮我好吗?
laravel laravel-routing laravel-upgrade laravel-authentication laravel-6
这让我第二天发疯。我是 Laravel 的新手,并试图让 Laravel 6 在 Google App Engine 标准上工作。尝试:本教程和其他教程,但仍然无法加载 Laravel 索引页面
我做了什么:
创建新的 Laravel 项目
检查 Laravel 是否在本地主机上工作 php artisan serve
生成的新密钥 php artisan key:generate --show
使用以下命令创建 app.yaml 文件:
runtime: php72
env_variables:
APP_KEY: iktbUa2quYPV2av3zDx0XAuEVjwzVQY/oMfyI2PQNKk=
APP_STORAGE: /tmp
VIEW_COMPILED_PATH: /tmp
SESSION_DRIVER: cookie
Run Code Online (Sandbox Code Playgroud)
通过添加修改 bootstrap/app.php $app->useStoragePath(env('APP_STORAGE', base_path() . '/storage'));
冉composer remove --dev beyondcode/laravel-dump-server
还跑了:
php artisan cache:clear
,
php artisan route:cache
,
php artisan config:clear
,
php artisan view:clear
(如其他教程所建议的那样)
和 gcloud app deploy
我得到错误:“找不到类‘Facade\Ignition\IgnitionServiceProvider’ ”
我最近遇到了一个问题,我需要更改 Laravel 的供应商文件之一以获得所需的结果。该文件是vendor/laravel/framework/Illuminate/Routing/CompileRouteCollection.php
.
在该文件内,需要更改一个函数。
protected function requestWithoutTrailingSlash(Request $request)
{
$trimmedRequest = Request::createFromBase($request);
$parts = explode('?', $request->server->get('REQUEST_URI'), 2);
$trimmedRequest->server->set(
'REQUEST_URI', rtrim($parts[0], '/').(isset($parts[1]) ? '?'.$parts[1] : '')
);
return $trimmedRequest;
}
Run Code Online (Sandbox Code Playgroud)
更具体地说,这部分:rtrim($parts[0], '/')
. 为了使我的部分路线正常工作,需要删除最后的 / 。
我尝试在里面创建我自己的自定义类:App\Helpers\CompiledRouteCollection.php
. 我在其中复制上面列出的函数并进行自己的更改。
应用\Helpers\CompiledRouteCollection.php
namespace App\Helpers;
use Illuminate\Http\Request;
class CompiledRouteCollection extends \Illuminate\Routing\CompiledRouteCollection
{
protected function requestWithoutTrailingSlash(Request $request)
{
$trimmedRequest = Request::createFromBase($request);
$parts = explode('?', $request->server->get('REQUEST_URI'), 2);
$trimmedRequest->server->set(
'REQUEST_URI', rtrim($parts[0], '').(isset($parts[1]) ? '?'.$parts[1] : '')
);
return $trimmedRequest;
}
}
Run Code Online (Sandbox Code Playgroud)
然后我进入 App\Providers\AppServiceProvider …