add nova
This commit is contained in:
43
nova/src/Fields/PeekableFields.php
Normal file
43
nova/src/Fields/PeekableFields.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Laravel\Nova\Fields;
|
||||
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
|
||||
trait PeekableFields
|
||||
{
|
||||
/**
|
||||
* Indicates whether to show the field in the modal preview.
|
||||
*
|
||||
* @var (callable(\Laravel\Nova\Http\Requests\NovaRequest):(bool))|bool
|
||||
*/
|
||||
public $showWhenPeeking = false;
|
||||
|
||||
/**
|
||||
* Show the field in the modal preview.
|
||||
*
|
||||
* @param (callable(\Laravel\Nova\Http\Requests\NovaRequest):(bool))|bool $callback
|
||||
* @return $this
|
||||
*/
|
||||
public function showWhenPeeking($callback = true)
|
||||
{
|
||||
$this->showWhenPeeking = $callback;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the field is to be shown in the preview modal.
|
||||
*
|
||||
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||
* @return bool
|
||||
*/
|
||||
public function isShownWhenPeeking(NovaRequest $request): bool
|
||||
{
|
||||
if (is_callable($this->showWhenPeeking)) {
|
||||
$this->showWhenPeeking = call_user_func($this->showWhenPeeking, $request);
|
||||
}
|
||||
|
||||
return $this->showWhenPeeking;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user