laravel-nova 相关问题

Nova是Laravel的管理小组,由Laravel的创作者制作

在laravel nova action fields函数中获取对应模型

如何在 laravel nova actions 字段函数中获取当前模型?查不出来... 公共函数字段(NovaRequest $request) { 日志::信息($请求->模型()); 返回 [ ...

回答 1 投票 0

Laravel Nova 4 格式日期在 BelongsTo 字段中

我恳求您的支持,以了解如何将原始资源中所示的相同日期格式应用于 Laravel Nova 4 中的 ownTo 字段。 资源1 公共函数字段(请求$

回答 1 投票 0

同一张表的多对多关系

我有表“项目”,其中包含字段 BasedOnId 我想在当前表中创建 morphToMany 关系 在资源项目中我创建字段 BelongsToMany::make(\App\Nova\Projects::la...

回答 1 投票 0

如何在 laravel nova 中挂钩资源的删除事件?

我有一个查询,我想在从 Nova 删除特定资源时从服务器删除图像。 谁能建议我有什么方法可以覆盖资源的删除方法。 电子数据交换...

回答 4 投票 0

自定义 Laravel Nova 破坏性动作模式

我正在使用文档在 Laravel Nova 中定义一个新的破坏性操作,我想知道是否可以自定义模式消息,其中显示“您确定要运行这个吗?”

回答 2 投票 0

如何隐藏 Laravel Nova 上的编辑/删除/查看按钮?

所以我试图隐藏 Laravel Nova 资源中的按钮。但我不知道我可以在代码中添加什么。 这些按钮:

回答 2 投票 0

Laravel Nova。未找到列:1054 未知列“*.deleted_at”

我正在使用 Laravel Nova v4。 使用软删除时,出现错误 Column not found: 1054 Unknown column '*.deleted_at',其中 * 是我使用它的实体的表。 完整的 SQL 请求...

回答 1 投票 0

Laravel 多态关系在 Laravel Nova 中不起作用

我有以下模型和关系。 应用程序\订阅者.php 我有以下模型和关系。 应用程序\订阅者.php <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Grosv\LaravelPasswordlessLogin\Traits\PasswordlessLogin; class Subscriber extends Authenticatable { use Notifiable, PasswordlessLogin; public function customFieldValues() { return $this->morphMany(CustomFieldValue::class, 'customFieldValueable'); } } 应用程序\CustomField.php <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use App\Models\Campaign; class CustomField extends Model { protected $fillable = [ 'name', 'key', 'type', 'field_options' ]; public function customFieldValues() { return $this->hasMany(CustomFieldValue::class); } } 应用程序\CustomFieldValues.php <?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class CustomFieldValue extends Model { use HasFactory; protected $fillable = ['custom_field_id', 'value', 'custom_field_valueable_id', 'custom_field_valueable_type']; public function customField() { return $this->belongsTo(CustomField::class); } public function customFieldValueable() { // If you are using custom column names, specify them here. Otherwise, ensure they match the migration. return $this->morphTo(null, 'custom_field_valueable_type', 'custom_field_valueable_id'); } } 应用\Campaign.php <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use App\Models\CustomField; class Campaign extends Model { protected $dates = [ 'imported_at' ]; protected $casts = [ 'imported_at' => 'datetime', 'exported_at' => 'datetime' ]; protected $fillable = [ 'uuid', 'name', 'slug', 'client_id' ]; public function customFieldValues() { return $this->morphMany(CustomFieldValue::class, 'customFieldValueable'); } } 应用\Newsletter.php <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Newsletter extends Model { protected $fillable = [ 'uuid', 'name', 'brand_id', 'active', 'create_send_list_id', 'last_imported' ]; public function brand() { return $this->belongsTo(Brand::class); } public function subscribers() { return $this ->belongsToMany(Subscriber::class) ->withPivot('active') ->withTimestamps(); } public function customFieldValues() { return $this->morphMany(CustomFieldValue::class, 'customFieldValueable'); } } 我创建表来支持这一点的迁移看起来像这样, <?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. */ public function up(): void { Schema::create('custom_field_values', function (Blueprint $table) { $table->id(); $table->unsignedBigInteger('custom_field_id'); $table->string('value'); // Manually create the polymorphic columns $table->unsignedBigInteger('custom_field_valueable_id'); $table->string('custom_field_valueable_type'); // Manually specify a shorter index name $table->index(['custom_field_valueable_type', 'custom_field_valueable_id'], 'custom_field_valueable_index'); $table->timestamps(); $table->foreign('custom_field_id')->references('id')->on('custom_fields')->onDelete('cascade'); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('custom_field_values'); } }; 但是,在 Nova 界面中,当我尝试查看订阅者时,出现以下错误, SQLSTATE[42S22]:未找到列:1054“where 子句”中的未知列“custom_field_values.customFieldValueable_type”(连接:mysql,SQL:从custom_field_values中选择*,其中custom_field_values。customFieldValueable_type = App\Models\Subscriber且 custom_field_values.customFieldValueable_id = 1016 且 custom_field_values.customFieldValueable_id 不为空,按 custom_field_values.id desc limit 6 offset 0) 如果有人可以向我解释我哪里出了问题,那就太好了。我对多态关系非常陌生。 laravel 查询正在寻找列 customFieldValueable_type 但您的数据库中有一个 custom_field_valueable_type 。 如果您重新使用标准命名约定,它应该可以正常工作。 错误似乎来自于函数中的App\CustomFieldValues.php: public function customFieldValueable() { // If you are using custom column names, specify them here. Otherwise, ensure they match the migration. return $this->morphTo(null, 'custom_field_valueable_type', 'custom_field_valueable_id'); } 正确的命名约定可以在这里在 laravel 文档中找到

回答 1 投票 0

如何在 laravel nova 中创建自引用关系

我有一个名为“产品”的模型。该产品与一个类别相关联,每个类别都有许多功能。此外,每个功能都有相当数量的功能项。 我

回答 1 投票 0

在 laravel nova 中的关系中创建关系

我有一个名为“产品”的模型。该产品与一个类别相关联,每个类别都有许多功能。此外,每个功能都有相当数量的功能项。 我

回答 1 投票 0

Laravel Nova 不使用数组键作为过滤器中的选项值

我为 Nova v4.32.11 创建了这个过滤器: AccountFilter 类扩展 Filter { 公共函数应用(请求$请求,$查询,$值) { 返回 $query->where('account_id', $value)...

回答 1 投票 0

如何在 Nova 4 中通过外部 url 在字段中显示 gif 图像

我在 nova 4 上遇到了问题,因为我在 nova 2 中使用了 chasconey/nova-external-image 包,但升级到 nova 4 版本后,我无法使用这个包。 你知道一些关于 sh... 的包或技巧吗?

回答 1 投票 0

BelongsTo 字段上的可搜索方法在 Laravel Nova 中不起作用,不返回任何项目

我有一个名为 Customer 的模型,它与 Notes 模型有很多关系 公共函数注释() { 返回 $this->hasMany(注意::class); } 并且注释与客户有BelongsTo 关系 ...

回答 3 投票 0

有没有办法在 Laravel 中明确定义 Nova 资源的策略?

场景是我希望能够独立于其他用户管理员工用户类型。只有员工应该能够查看员工资源并与之交互,其他用户类型不应该拥有...

回答 3 投票 0

索引视图上的 Laravel Nova 资源工具

我可以将自定义资源工具添加到资源的详细视图中。 Laravel Nova 文档说: ...资源工具显示特定资源的详细信息 屏幕 如何添加资源...

回答 2 投票 0

尝试通过 Composer 将 Laravel/Nova 更新到最新版本时出现 INVALID CREDENTIALS 错误

我已经尝试了两天来更新Nova 将composer.json 文件正确设置为更新过程似乎正在运行的位置后,我收到了身份验证错误。 帕克...

回答 2 投票 0

关系搜索在 laravel nova 中不起作用

我有一个父资源。假设团队和内部团队资源详细信息页面我使用以下代码显示其他资源,例如受众资源。 HasMany::make('观众') 现在这个

回答 1 投票 0

更新依赖项后在 Laravel Nova 中渲染组件时出现问题

Stack Overflow 社区您好! 更新项目中的依赖项后,我在 Laravel Nova 中渲染组件时遇到问题。当尝试在 Laravel Nova 中打开组件时,我得到一个

回答 1 投票 0

Laravel Nova 将一个过滤器的值传递给另一个过滤器

我正在尝试使用 2 个“选择过滤器”来过滤 Laravel Nova 资源(评论)数据。 我有一个过滤器 A = 制造商,过滤器 B = 型号。 制造商有许多型号。我有制造商和...

回答 2 投票 0

Laravel Nova:如何拒绝在更新时更改字段值?

如何在 Laravel Nova 更新时拒绝更改字段值? 该字段在创建时应该是可编辑的。 我试图用观察者保存以前的值,但有些东西告诉我这不是一个选择......

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.