forked from whitecube/nova-flexible-content
-
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.
Merge pull request whitecube#291 from marshmallow-packages/289-depend…
…ed-layout Use depended fields
Showing
3 changed files
with
214 additions
and
1 deletion.
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
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,61 @@ | ||
<?php | ||
|
||
namespace Marshmallow\Nova\Flexible\Layouts; | ||
|
||
use Laravel\Nova\Fields\Select; | ||
use Laravel\Nova\Http\Requests\NovaRequest; | ||
|
||
class DependedLayout extends MarshmallowLayout | ||
{ | ||
/** | ||
* The layout's unique identifier | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'depended-layout'; | ||
|
||
/** | ||
* The displayed title | ||
* | ||
* @var string | ||
*/ | ||
protected $title = 'Mirror another layout'; | ||
|
||
/** | ||
* Description as shown in the layout selector. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Copy any layout from another resource and mirror it here.'; | ||
|
||
/** | ||
* Image use in the layout selector | ||
* | ||
* @var string | ||
*/ | ||
protected $image = 'https://marshmallow.dev/cdn/flex/layout/dividers.png'; | ||
|
||
/** | ||
* Add this layout to these tags. | ||
* | ||
* @var array | ||
*/ | ||
protected $tags = ["Specials"]; | ||
|
||
/** | ||
* Get the fields displayed by the layout. | ||
* | ||
* @return array | ||
*/ | ||
public function fields() | ||
{ | ||
$resource_model = NovaRequest::createFrom(request()) | ||
->model(); | ||
|
||
return [ | ||
Select::make(__('Depended Layout'), 'layout')->options( | ||
$resource_model::getOptionsForDependedLayoutSelect(), | ||
)->displayUsingLabels()->searchable(), | ||
]; | ||
} | ||
} |