laravel-nova

Laravel Nova - How to determine the view (index, detail, form) you are in for a resource's computed field?

核能气质少年 提交于 2020-05-15 06:21:05
问题 I would like to return a different result for a computed field when viewing the index view than when viewing the detail view of a resource. Basically something like viewIs() below: Text::make('Preview', function () { if($this->viewIs('index'){ return \small_preview($this->image); } return \large_preview($this->image); })->asHtml(), 回答1: You can check the class of the request: Text::make('Preview', function () use ($request) { if ($request instanceof \Laravel\Nova\Http\Requests

Laravel nova resource extending/overriding the create method

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 18:30:50
问题 I am developing a web admin panel using Laravel Nova. I am having an issue since Nova is quite a new technology. What I would like to do now is I would like to add a hidden field or extend or override the create method. This is my scenario. Let's save I have a vacancy nova resource with the following field. public function fields(Request $request) { return [ ID::make()->sortable(), Text::make('Title')->sortable(), Text::make('Salary')->sortable() // I will have another field, called created

How do you use confirm dialogues in a custom Laravel Nova tool?

不羁的心 提交于 2019-12-21 07:06:33
问题 Is it possible to use the built in Laravel Nova confirm dialogue in your own tool? All I would like to use is interact with it how Nova does itself. The docs are quite light on the JS topic, as the only built in UI you seem to be able to work with is the toasted plugin: https://nova.laravel.com/docs/1.0/customization/frontend.html#javascript 回答1: You can use <modal> component whenever you want. Here is how it work internally in Nova: https://gist.github.com/sanasol

Laravel Nova - Map database json column to field

久未见 提交于 2019-12-20 04:24:11
问题 I have a database model with json column type called attributes . This column will contain additional details of the model. For example: attributes : {'desc' : 'test', 'width' : '500'} . I would like to display individual attribute ( desc & width ) in attributes column as a html field in Laravel admin resource. I checked supported field types and doesn't seem supports. Any suggestions how I can do this? 回答1: I'm not sure if it's the recommended answer but i've found a way that should work for

Laravel Nova - Only load relationship with certain property in form dropdown

此生再无相见时 提交于 2019-12-19 19:55:08
问题 I have added a BelongsTo relationship field(relationship name: user) in my Nova app in resource named "Partner". So in the "create partner" form now I have a select element to choose a specific user. The relationship I have written includes a condition: $this->belongsTo('App\User')->where('role', 'partner'); In the select dropdown, instead of only showing users with role "partner", all users of the app are listing. How can I fix this issue? User table : id, name, role Partner table : id, user

Laravel Nova - Point Nova path to resource page

こ雲淡風輕ζ 提交于 2019-12-14 02:04:10
问题 I need to point Nova path to a resouce. So that when a user login, he`ll directed to that particular resource. I have updated this path in /config/nova.php : 'path' => '/crm/resources/clients' Now after login, I can see the URL updated. But the page is still Welcome Nova page. Any idea on this? 回答1: The path settings in config/nova.php is the URI path where Nova will be accessible from. For example if you set path' => '/crm , then client resource index URL will be /crm/resources/clients

Fresh Nova install, yet cannot delete newly created Users

为君一笑 提交于 2019-12-11 19:54:47
问题 This is a new Laravel Nova install. I added a few test users, but I am unable to delete any. After confirming that I wish to delete the Resource, nothing happens. Refresh shows nothing was deleted. The Laravel Log is empty. APP_ENV=local APP_DEBUG=true I have installed Vue Devtools and compiled npm to dev mode, so I am seeing the Vue Console errors. I haven't added any code and am running the latest - Laravel Framework 5.8.29, Nova 2.0.9, PHP 7.3.7 Attempting to Delete User with ID 4.

Laravel nova - Custom field set value based on another field and still editable

拜拜、爱过 提交于 2019-12-11 15:29:40
问题 laravel 5.8 Nova 2.0.0 I have two field based on first field I want to set the value of second and it is upto the user to use the set value or may insert a new one and submit the form. I am adding custom field like CustomField::make('Field 2', 'field_2')->dependsOn('field_1'), Now in CustomField class dependsOn() method I can access, the dependsOn field name, that is field_1 , also in Vue > FormField.vue I can access it as {{ field.dependsOnField }} in template and as console.log(this.field

Thousand separator in forms

[亡魂溺海] 提交于 2019-12-10 16:16:45
问题 I'm trying to add thousand separators to my inputs, how can I do it? I tried to use Laravel\Nova\Fields\Currency in my fields() method, but it doesn't help. It still shows value in the input like: 100000 And I want to show it like: 100,000 How can I achieve it in Laravel Nova? public function fields(Request $request) { $fields = []; ... $fields[] = Currency::make(__('Price'), 'price'); return $fields; } 回答1: use number_format() doc or money_format() doc (won't work on windows), which were