我需要在 Laravel 8 中禁用我的注册路由。试过
Auth::routes([
'register' => false,
'login' => false,
]);
Run Code Online (Sandbox Code Playgroud)
但是应用程序抛出了一个错误。
RuntimeException
In order to use the Auth::routes() method, please install the laravel/ui package.
Run Code Online (Sandbox Code Playgroud)
如果有人指出需要改变的地方,将不胜感激。
谢谢
当我发帖并点击我的活动时,我收到此错误
调用未定义的方法 App\Events\UpdateProductCount::__invoke()
这是我的代码
public function create()
{
$product = Product::create([
'name' => request('name'),
'description' => request('description'),
]);
dispatch(new UpdateProductCount($product));
}
Run Code Online (Sandbox Code Playgroud)
这就是我在 UpdateProductCount 事件中的内容
<?php
namespace App\Events;
use App\Models\Product;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class UpdateProductCount
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public Product $product;
public function __construct(Product $product)
{
$this->product = $product;
}
public function broadcastOn()
{
return new PrivateChannel('product-count-update'.$this->product);
}
}
Run Code Online (Sandbox Code Playgroud)
这就是我的 UpdateProductCountListener 中的内容
<?php
namespace App\Listeners;
use App\Events\UpdateProductCount;
use …Run Code Online (Sandbox Code Playgroud) 嗨,我刚刚尝试安装带有风帆的 Laravel 8,但遇到了问题
我所做的是首先从 Laravel 自己的页面运行 curl one-liner
curl -s https://laravel.build/sail-test | bash
Run Code Online (Sandbox Code Playgroud)
一旦完成我就按照它说的运行
cd sail-test && ./vendor/bin/sail up
Run Code Online (Sandbox Code Playgroud)
一切都按原样开始,我可以连接到数据库,我可以在 http://localhost 上看到该站点,但是在尝试迁移时出现以下错误:
$ sail artisan migrate:install
Illuminate\Database\QueryException
SQLSTATE[HY000] [2002] No route to host (SQL: create table `migrations` (`id` int unsigned not null auto_increment primary key, `migration` varchar(255) not null, `batch` int not null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:678
674? // If an exception occurs when attempting to run a query, we'll format the error
675? // message …Run Code Online (Sandbox Code Playgroud) 在 web.php 路由中,我有以下内容:
Route::middleware('throttle:3,1')->group(function () {
Route::get('/about', function () {
return "About Info";
});
});
Run Code Online (Sandbox Code Playgroud)
Laravel 框架是 8.19.0。
理想情况下,当有人在 1 分钟内点击页面超过 3 次时,laravel 应该给出 429 Too Many Attempts 响应。但事实并非如此。3 次后我没有收到 429 响应。
如何解决这个问题?
谢谢
我正在开发一个 Laravel Reactjs 项目,当我运行命令时,npm run dev编译停留在 95% 并给出以下错误。我检查了整个项目,没有使用区分大小写的名称进行文件调用,所有图像都使用小写字母进行调用。
Error: Prevent writing to file that only differs in casing or query string from already written file.
This will lead to a race-condition and corrupted files on case-insensitive file systems.
/media/public/images/user-4.jpg
/media/public/images/user-4.jpg
Run Code Online (Sandbox Code Playgroud)
反应:17.0.1
网络包:5.21.2
节点:14.15.2
类别型号
\nclass Category extends Model\n{\nuse HasFactory;\n\nprotected $fillable= ['name','number'];\n\n public function news(){\n\n return $this->hasMany(News::class);\n}\nRun Code Online (Sandbox Code Playgroud)\n新闻模型
\nclass News extends Model\n{\nuse HasFactory;\n\nprotected $fillable= ['cat_id','title','photo','description','author_id','status'];\n\n public function category(){\n return $this->belongsTo(Category::class);\n }\n\n public function author(){\n return $this->belongsTo(Author::class);\n }\nRun Code Online (Sandbox Code Playgroud)\n作者模型
\nclass Author extends Model\n{\nuse HasFactory;\n\nprotected $fillable= ['name','status'];\n\npublic function news(){\n return $this->hasMany(News::class);\n}\nRun Code Online (Sandbox Code Playgroud)\n3个模型之间存在关系。我想在 中显示类别名称而不是category_id news-list.blade.php。我收到此错误。
这是我的控制器功能
\n public function news_index(){\n $news= News::with('category')->get();\n return view('News.list',compact('news'));\n}\nRun Code Online (Sandbox Code Playgroud)\n这是我的刀片页面。$new->category->name当我输入而不是 时出现错误cat_id。
@foreach($news as $new)\n <tr>\n <th scope="row">{{$loop->iteration}}</th>\n <td> …Run Code Online (Sandbox Code Playgroud) 我在用户表和区域表之间有一对多的关系,当我返回配置文件数据时,我从用户表中获取area_id,我需要使用模型获取区域名称。有没有办法在个人资料视图中获取区域名称?我尝试在 show.vue 中调用模型函数,但它不起作用。
用户.php
public function area()
{
return $this->belongsTo(Area::class);
}
Run Code Online (Sandbox Code Playgroud)
区域.php
public function users()
{
return $this->hasMany(User::class);
}
Run Code Online (Sandbox Code Playgroud)
显示.vue
<template>
<app-layout>
<template #header>
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
Profile
</h2>
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
Area :
</h2>
</template>
<div>
<div class="max-w-7xl mx-auto py-10 sm:px-6 lg:px-8">
<div v-if="$page.props.jetstream.canUpdateProfileInformation">
<update-profile-information-form :user="$page.props.user" />
<jet-section-border />
</div>
<div v-if="$page.props.jetstream.canUpdatePassword">
<update-password-form class="mt-10 sm:mt-0" />
<jet-section-border />
</div>
<div v-if="$page.props.jetstream.canManageTwoFactorAuthentication">
<two-factor-authentication-form class="mt-10 sm:mt-0" />
<jet-section-border />
</div>
<logout-other-browser-sessions-form :sessions="sessions" class="mt-10 sm:mt-0" />
<template v-if="$page.props.jetstream.hasAccountDeletionFeatures"> …Run Code Online (Sandbox Code Playgroud) 我使用以下命令创建了一个 artisan 命令:
php artisan make:command --command=custom:command SomeCustomCommand
Run Code Online (Sandbox Code Playgroud)
运行命令后,它创建了以下文件:
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class SomeCustomCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'custom:command';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* …Run Code Online (Sandbox Code Playgroud) 我有一个 Laravel sail 项目,但是当我输入 sail 命令时,控制台没有任何反应。
只有sail up和sail down工作正常,但其他命令如sail shell, sail artisan ***,sail php -v ......不响应。没有错误,也没有任何反应。
我不知道发生了什么?
sail shell并且sail artisan命令已停止工作。
但sail up仍在sail down工作。
版本详情
php: 8.0.5
laravel: 8.41.0
sail: 1.5.1
docker: 3.3.3
操作系统: macOS 11.3.1
我的 docker-compose.yml 文件
# For more information: https://laravel.com/docs/sail
version: '3'
services:
laravel.test:
build:
context: ./vendor/laravel/sail/runtimes/8.0
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
image: sail-8.0/app
ports:
- '${APP_PORT:-80}:80'
environment:
WWWUSER: '${WWWUSER}'
LARAVEL_SAIL: 1
volumes:
- '.:/var/www/html'
networks:
- sail
depends_on:
- mysql
mysql:
image: 'mysql:8.0'
ports:
- '${FORWARD_DB_PORT:-3306}:3306'
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
MYSQL_DATABASE: '${DB_DATABASE}'
MYSQL_USER: '${DB_USERNAME}'
MYSQL_PASSWORD: '${DB_PASSWORD}'
MYSQL_ALLOW_EMPTY_PASSWORD: …Run Code Online (Sandbox Code Playgroud)