107 lines
2.5 KiB
PHP
107 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Nova;
|
|
|
|
use Laravel\Nova\Fields\ID;
|
|
use Illuminate\Http\Request;
|
|
use Laravel\Nova\Fields\Text;
|
|
use Laravel\Nova\Fields\HasMany;
|
|
use Laravel\Nova\Fields\Textarea;
|
|
use Laravel\Nova\Fields\BelongsTo;
|
|
use Laravel\Nova\Http\Requests\NovaRequest;
|
|
|
|
class Comment extends Resource
|
|
{
|
|
/**
|
|
* The model the resource corresponds to.
|
|
*
|
|
* @var string
|
|
*/
|
|
public static $model = \App\Domain\Comments\Models\Comment::class;
|
|
public static $group = 'Content';
|
|
/**
|
|
* The single value that should be used to represent the resource when being displayed.
|
|
*
|
|
* @var string
|
|
*/
|
|
public static $title = 'body';
|
|
|
|
/**
|
|
* The columns that should be searched.
|
|
*
|
|
* @var array
|
|
*/
|
|
public static $search = [
|
|
'id', 'body'
|
|
];
|
|
|
|
/**
|
|
* Get the fields displayed by the resource.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function fields(Request $request)
|
|
{
|
|
return [
|
|
ID::make(__('ID'), 'id')->sortable(),
|
|
BelongsTo::make('Creator', 'user', 'App\Nova\User')
|
|
->onlyOnIndex(),
|
|
BelongsTo::make('Feed')
|
|
->readonly(),
|
|
Text::make('Body')
|
|
->displayUsing(function($id) {
|
|
$part = strip_tags(mb_substr($id, 0, 100));
|
|
return $part . " ...";
|
|
})->onlyOnIndex(),
|
|
BelongsTo::make('Parent', 'parent', \App\Nova\Comment::class),
|
|
HasMany::make('Children', 'children', \App\Nova\Comment::class),
|
|
Textarea::make('Body')->alwaysShow()->showOnDetail(),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 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 [];
|
|
}
|
|
}
|