From: Louis Jeckel Date: Fri, 30 Oct 2020 12:25:36 +0000 (+0100) Subject: new lens + searchable X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=8bb9986211d1aebe3df76a60d6a4dedbbb064b0b;p=psq.git new lens + searchable --- diff --git a/app/Nova/Lenses/SentEmailToAdmin.php b/app/Nova/Lenses/SentEmailToAdmin.php new file mode 100644 index 0000000..eb4d0e6 --- /dev/null +++ b/app/Nova/Lenses/SentEmailToAdmin.php @@ -0,0 +1,95 @@ +withOrdering($request->withFilters( + $query->where('recipient', 'like', '%prescription-quotidien.com') + )); + } + + /** + * Get the fields available to the lens. + * + * @param \Illuminate\Http\Request $request + * @return array + */ + public function fields(Request $request) + { + return [ + Text::make('Destinataire', 'recipient'), + Text::make('Objet', 'subject'), + Iframe::make('Contenu', 'content')->onlyOnDetail(), + Badge::make('Etat mail', fn() => MailgunEvent::STATUSES[$this->status ?? 'unknown']['label']) + ->map(Arr::pluck(MailgunEvent::STATUSES, 'badge', 'label')), + DateTime::make('Envoyé le', 'created_at'), + DateTime::make('Dernier événement', 'updated_at')->onlyOnDetail() + ]; + } + + /** + * Get the cards available on the lens. + * + * @param \Illuminate\Http\Request $request + * @return array + */ + public function cards(Request $request) + { + return []; + } + + /** + * Get the filters available for the lens. + * + * @param \Illuminate\Http\Request $request + * @return array + */ + public function filters(Request $request) + { + return []; + } + + /** + * Get the actions available on the lens. + * + * @param \Illuminate\Http\Request $request + * @return array + */ + public function actions(Request $request) + { + return parent::actions($request); + } + + /** + * Get the URI key for the lens. + * + * @return string + */ + public function uriKey() + { + return 'sent-email-to-admin'; + } +} diff --git a/app/Nova/SentEmail.php b/app/Nova/SentEmail.php index a54dde1..f29eb1e 100644 --- a/app/Nova/SentEmail.php +++ b/app/Nova/SentEmail.php @@ -4,6 +4,7 @@ namespace App\Nova; use App\MailgunEvent; use App\Nova\Filters\EmailStatusFilter; +use App\Nova\Lenses\SentEmailToAdmin; use Illuminate\Http\Request; use Illuminate\Support\Arr; use Laravel\Nova\Fields\Badge; @@ -24,6 +25,14 @@ class SentEmail extends Resource public static $model = \App\SentEmail::class; + public static $globallySearchable = false; + + public static $search = [ + 'subject', + 'recipient', + 'content' + ]; + /** * @var string */ @@ -135,7 +144,9 @@ class SentEmail extends Resource */ public function lenses(Request $request) { - return []; + return [ + new SentEmailToAdmin + ]; } /**