laravel-nova 相关问题

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

在 Nova Laravel 中创建发票视图

我正在使用 Nova 开发一个项目,我需要为发票模型创建一个标准发票视图资源。我不确定最好的方法,希望得到一些指导。 这里是...

回答 1 投票 0

将 Laravel Nova 移至子域

我想将 Laravel Nova 移至 nova.mydomain.com,而不是 mydomain.de/nova。我已经搜索过 GitHub 和 Stackoverflow,但是这些解决方案对我不起作用。目前我正在尝试...

回答 2 投票 0

我的 Laravel 模型中有多态关系。如何在 Nova 中实现它们?

下面是实体结构 考试 -> 可以有“描述性问题”或“多项选择题”,具体取决于考试类型。 公共职能问题() { 开关($this->exam_type)...

回答 1 投票 0

在 Laravel Nova 的详细信息视图上显示模型的 Repeater 字段 JSON 数据

我正在资源上使用中继器字段,该字段看起来非常适合编辑,但如何显示它保存到我的详细信息页面的 json 数据?我假设我使用 KeyValue 字段来显示...

回答 1 投票 0

Laravel Nova - 更新资源的确认模式

有没有办法显示确认模式,例如删除更新案例的资源时?请参阅下面的屏幕截图。 我还没有找到任何解决方案。我看到了几个类似的问题,但没有人...

回答 1 投票 0

在 Nova Action fields() 上运行 where()->get()

我试图提供一个选择列表,其中仅包含通过数据透视表与模型相关的记录。 在为客户构建时间跟踪器/预算软件时,我正在使用两个模型......

回答 5 投票 0

使用 Spatie Laravel 权限在 Nova 上分配用户角色

我目前在 laravel 5.8 项目中使用 spatie laravel 权限包,并使用 Nova 进行管理。 我希望超级管理员用户能够为 nova 中选定的用户分配角色

回答 1 投票 0

Laravel Nova 4 属于取决于

我有两个表,类别和产品,我将gategory id设置为产品。在我的订单页面中,我想根据我在类别中选择的产品来选择产品。 这是我的代码,它确实...

回答 1 投票 0

在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

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