Skip to content

Commit

Permalink
fix label not displaying correctly on index view when using associati…
Browse files Browse the repository at this point in the history
…ve types
  • Loading branch information
milewski committed Oct 2, 2019
1 parent 31c0a9d commit d4f7d8a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/HasInlineMorphToFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace DigitalCreative\InlineMorphTo;

use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Collection;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Nova;

Expand All @@ -11,9 +12,9 @@ trait HasInlineMorphToFields
/**
* Resolve the index fields.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @param NovaRequest $request
*
* @return \Illuminate\Support\Collection
* @return Collection
*/
public function detailFields(NovaRequest $request)
{
Expand Down
15 changes: 8 additions & 7 deletions src/InlineMorphTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace DigitalCreative\InlineMorphTo;

use App\Nova\Resource;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
Expand Down Expand Up @@ -72,7 +73,7 @@ public function types(array $types): self

});

$this->withMeta([ 'resources' => $types ]);
$this->withMeta([ 'resources' => $types->values() ]);

return $this;

Expand All @@ -94,8 +95,8 @@ private function convertToHumanCase(string $resource): string
protected function resolveAttribute($resource, $attribute)
{
/**
* @var null|\Illuminate\Database\Eloquent\Model $relationInstance
* @var \Laravel\Nova\Fields\Field $field
* @var null|Model $relationInstance
* @var Field $field
*/

if ($relationInstance = $resource->$attribute) {
Expand Down Expand Up @@ -128,10 +129,10 @@ public function fill(NovaRequest $request, $model)
{

/**
* @var \Illuminate\Database\Eloquent\Model $relatedInstance
* @var \Illuminate\Database\Eloquent\Model $model
* @var \App\Nova\Resource $resource
* @var \Laravel\Nova\Fields\Field $field
* @var Model $relatedInstance
* @var Model $model
* @var Resource $resource
* @var Field $field
*/

$resourceClass = $request->input($this->attribute);
Expand Down

0 comments on commit d4f7d8a

Please sign in to comment.