Created
January 9, 2020 08:58
-
-
Save tompec/53108f575aa277102fdcca5e14543c06 to your computer and use it in GitHub Desktop.
Laravel Nova resource for the EmailLog model from https://github.com/tompec/laravel-email-log
This file contains hidden or 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
<?php | |
namespace App\Nova; | |
use Illuminate\Http\Request; | |
use Laravel\Nova\Fields\Boolean; | |
use Laravel\Nova\Fields\DateTime; | |
use Laravel\Nova\Fields\ID; | |
use Laravel\Nova\Fields\MorphOne; | |
use Laravel\Nova\Fields\Text; | |
use Laravel\Nova\Fields\Trix; | |
class EmailLog extends Resource | |
{ | |
/** | |
* The model the resource corresponds to. | |
* | |
* @var string | |
*/ | |
public static $model = 'Tompec\EmailLog\EmailLog'; | |
/** | |
* The single value that should be used to represent the resource when being displayed. | |
* | |
* @var string | |
*/ | |
public static $title = 'id'; | |
/** | |
* The columns that should be searched. | |
* | |
* @var array | |
*/ | |
public static $search = [ | |
'id', | |
'subject', | |
]; | |
/** | |
* Get the fields displayed by the resource. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @return array | |
*/ | |
public function fields(Request $request) | |
{ | |
return [ | |
ID::make()->sortable(), | |
Text::make('From')->hideFromIndex(), | |
Text::make('To'), | |
Text::make('Subject'), | |
Boolean::make('Delivered', function () { | |
return $this->delivered_at; | |
})->onlyOnIndex(), | |
Trix::make('Body')->stacked()->alwaysShow(), | |
MorphOne::make('Recipient', 'recipient', User::class), | |
DateTime::make('Delivered At')->onlyOnDetail(), | |
DateTime::make('Failed At')->onlyOnDetail(), | |
DateTime::make('Opened At')->onlyOnDetail(), | |
DateTime::make('Clicked At')->onlyOnDetail(), | |
]; | |
} | |
/** | |
* Get the cards available for the request. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @return array | |
*/ | |
public function cards(Request $request) | |
{ | |
return []; | |
} | |
/** | |
* Get the filters available for the resource. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @return array | |
*/ | |
public function filters(Request $request) | |
{ | |
return []; | |
} | |
/** | |
* Get the lenses available for the resource. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @return array | |
*/ | |
public function lenses(Request $request) | |
{ | |
return []; | |
} | |
/** | |
* Get the actions available for the resource. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @return array | |
*/ | |
public function actions(Request $request) | |
{ | |
return []; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment