-
-
Notifications
You must be signed in to change notification settings - Fork 539
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
102db9b
commit d80954c
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
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,62 @@ | ||
<?php | ||
|
||
namespace Statamic\Fieldtypes; | ||
|
||
use Statamic\CP\Column; | ||
use Statamic\Facades\GraphQL; | ||
use Statamic\Facades\Nav; | ||
use Statamic\GraphQL\Types\NavType; | ||
|
||
class Navs extends Relationship | ||
{ | ||
protected $categories = ['relationship']; | ||
protected $canEdit = false; | ||
protected $canCreate = false; | ||
protected $canSearch = false; | ||
protected $statusIcons = false; | ||
|
||
protected function toItemArray($id, $site = null) | ||
{ | ||
if ($nav = Nav::findByHandle($id)) { | ||
return [ | ||
'title' => $nav->title(), | ||
'id' => $nav->handle(), | ||
]; | ||
} | ||
|
||
return $this->invalidItemArray($id); | ||
} | ||
|
||
public function getIndexItems($request) | ||
{ | ||
return Nav::all()->sortBy('title')->map(function ($nav) { | ||
return [ | ||
'id' => $nav->handle(), | ||
'title' => $nav->title(), | ||
]; | ||
})->values(); | ||
} | ||
|
||
protected function getColumns() | ||
{ | ||
return [ | ||
Column::make('title'), | ||
]; | ||
} | ||
|
||
protected function augmentValue($value) | ||
{ | ||
return Nav::findByHandle($value); | ||
} | ||
|
||
public function toGqlType() | ||
{ | ||
$type = GraphQL::type(NavType::NAME); | ||
|
||
if ($this->config('max_items') !== 1) { | ||
$type = GraphQL::listOf($type); | ||
} | ||
|
||
return $type; | ||
} | ||
} |
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