wip
This commit is contained in:
67
app/Nova/Resources/User/UserSearchResource.php
Normal file
67
app/Nova/Resources/User/UserSearchResource.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova\Resources\User;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Nova\Resource;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
|
||||
class UserSearchResource extends Resource
|
||||
{
|
||||
/**
|
||||
* The model the resource corresponds to.
|
||||
*
|
||||
* @var class-string<\App\Models\Resources\User\UserSearchResource>
|
||||
*/
|
||||
public static $model = User::class;
|
||||
|
||||
/**
|
||||
* The debounce amount (in seconds) to use when searching this resource.
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
public static $debounce = 1;
|
||||
|
||||
/**
|
||||
* The number of results to display when searching for relatable resources without Scout.
|
||||
*
|
||||
* @var int|null
|
||||
*/
|
||||
public static $relatableSearchResults = 3;
|
||||
|
||||
/**
|
||||
* Get the value that should be displayed to represent the resource.
|
||||
*/
|
||||
public function title(): string
|
||||
{
|
||||
return $this->fullname.' - '.$this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the search result subtitle for the resource.
|
||||
*/
|
||||
public function subtitle(): string
|
||||
{
|
||||
return $this->phone_number ? mask_phone($this->phone_number) : '-';
|
||||
}
|
||||
|
||||
/**
|
||||
* The columns that should be searched.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $search = [
|
||||
'first_name', 'last_name', 'phone_number', 'email',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the fields displayed by the resource.
|
||||
*/
|
||||
public function fields(NovaRequest $request): array
|
||||
{
|
||||
return [
|
||||
ID::make()->sortable(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user