add nova
This commit is contained in:
41
nova/src/ManagesPresets.php
Normal file
41
nova/src/ManagesPresets.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova;
|
||||
|
||||
trait ManagesPresets
|
||||
{
|
||||
/**
|
||||
* Indicates the preset the field should use.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $preset = 'default';
|
||||
|
||||
/**
|
||||
* Define the preset the field should use, optionally providing a new preset class to add.
|
||||
*
|
||||
* @param string $preset
|
||||
* @param string|null $presetClass
|
||||
* @return $this
|
||||
*/
|
||||
public function preset($preset, $presetClass = null)
|
||||
{
|
||||
if (! is_null($presetClass)) {
|
||||
$this->presets[$preset] = $presetClass;
|
||||
}
|
||||
|
||||
$this->preset = $preset;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of the configured preset.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function newPreset()
|
||||
{
|
||||
return new $this->presets[$this->preset];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user