-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d64b3b3
commit 036c698
Showing
7 changed files
with
1,201 additions
and
1,230 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
export default { | ||
fetchAvailableResources(resourceName, fieldAttribute, params) { | ||
return Nova.request().get( | ||
`/nova-api/${resourceName}/associatable/${fieldAttribute}`, | ||
params | ||
) | ||
return Nova.request().get( | ||
`/nova-r64-tags/${resourceName}/associatable/${fieldAttribute}`, | ||
params | ||
); | ||
}, | ||
|
||
determineIfSoftDeletes(resourceName) { | ||
return Nova.request().get(`/nova-api/${resourceName}/soft-deletes`) | ||
}, | ||
} | ||
return Nova.request().get(`/nova-api/${resourceName}/soft-deletes`); | ||
} | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
export default { | ||
created() { | ||
const values = this.field.value.map( | ||
field => (this.field.labelKey ? field[this.field.labelKey] : field) | ||
); | ||
this.$set(this.field, 'value', values.join(', ')); | ||
if (this.field.value) { | ||
const values = this.field.value.map( | ||
field => (this.field.labelKey ? field[this.field.labelKey] : field) | ||
) | ||
this.$set(this.field, 'value', values.join(', ')) | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Route; | ||
|
||
// Associatable Resources... | ||
Route::get('/{resource}/associatable/{field}', 'AssociatableController@index'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace R64\Tags\Http\Controllers; | ||
|
||
use Laravel\Nova\Http\Requests\NovaRequest; | ||
use Laravel\Nova\Http\Controllers\AssociatableController as Controller; | ||
|
||
class AssociatableController extends Controller | ||
{ | ||
/** | ||
* List the available related resources for a given resource. | ||
* | ||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request | ||
* @return \Illuminate\Http\Response | ||
*/ | ||
public function index(NovaRequest $request) | ||
{ | ||
$fields = $request->newResource() | ||
->availableFields($request); | ||
|
||
$field = $fields->firstWhere('attribute', $request->field); | ||
|
||
if(!$field) { | ||
$rowField = $fields->firstWhere('component', 'nova-fields-tags'); | ||
$fields = collect($rowField->meta['fields']); | ||
$field = $fields->firstWhere('attribute', $request->field); | ||
} | ||
|
||
$withTrashed = $this->shouldIncludeTrashed( | ||
$request, $associatedResource = $field->resourceClass | ||
); | ||
|
||
return [ | ||
'resources' => $field->buildAssociatableQuery($request, $withTrashed)->get() | ||
->mapInto($field->resourceClass) | ||
->filter->authorizedToAdd($request, $request->model()) | ||
->map(function ($resource) use ($request, $field) { | ||
return $field->formatAssociatableResource($request, $resource); | ||
})->sortBy('display')->values(), | ||
'softDeletes' => $associatedResource::softDeletes(), | ||
'withTrashed' => $withTrashed, | ||
]; | ||
} | ||
} |
Oops, something went wrong.