You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+62-7Lines changed: 62 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,8 @@
1
1
# Nova Inline Relationship
2
2
3
3
## Introduction
4
-
Nova Inline Relationship is meant to present a relationship based property as an inline property for a Laravel Nova Resource.
4
+
Nova Inline Relationship is meant to present a relationship based property as an inline property for a Laravel Nova Resource. This project is under active development, and currently only supports singular relationships. You are welcome to request or contribute by opening an issue.
5
5
6
-
**This is a pre-release project in Active Development. Frequent Changes are expected**
7
6
8
7
## Requirements
9
8
@@ -17,14 +16,70 @@ You can install this package in a Laravel app that uses [Nova](https://nova.lara
After installation, your model should include the `KirschbaumDevelopment\NovaInlineRelationship\Traits\HasRelatedAttributes` trait and you must implement the `KirschbaumDevelopment\NovaInlineRelationship\Contracts\MappableRelationships` Contract.
22
+
23
+
You must also define a static `getPropertyMap` function in the model which should return the required mapping between local and related attribute.
24
+
25
+
**_NOTE:_** You must add relationships in `relationship.attribute` format in the map. Nested relationships are currently not supported.
26
+
27
+
```php
28
+
use KirschbaumDevelopment\NovaInlineRelationship\Traits\HasRelatedAttributes;
29
+
use KirschbaumDevelopment\NovaInlineRelationship\Contracts\MappableRelationships;
30
+
31
+
class Employee extends Model implements MappableRelationships
Once you add this relationship map you can use the keys for this relationship map as a normal attribute inside your model's nova resource.
60
+
61
+
**_NOTE:_** These fields are in essence [Computed Fields](https://nova.laravel.com/docs/2.0/resources/fields.html#computed-fields), and are subjected to the same limitations. Since they are not associated with a database column, these fields will not be `sortable`.
62
+
63
+
```php
64
+
namespace App\Nova;
65
+
66
+
class Employee extends Resource
67
+
{
68
+
69
+
//...
70
+
public function fields(Request $request)
71
+
{
72
+
return [
73
+
//...
74
+
75
+
Text::make('Phone #', 'phone')
76
+
->rules('required'),
23
77
24
-
## To-Do
25
-
-[x] Setup Repo
26
-
-[ ] Present a Relationship property as inline using computed field
27
-
-[ ] Update a Relationship property by overloading mutator magic method
0 commit comments