Последняя версия с сервера прошлого разработчика
This commit is contained in:
150
app/Nova/Feed.php
Executable file
150
app/Nova/Feed.php
Executable file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace App\Nova;
|
||||
|
||||
use App\Domain\Feeds\Enums\StatusEnum;
|
||||
use Laravel\Nova\Fields\ID;
|
||||
use Illuminate\Http\Request;
|
||||
use Laravel\Nova\Fields\Text;
|
||||
use Laravel\Nova\Fields\Select;
|
||||
use Laravel\Nova\Fields\HasMany;
|
||||
use Laravel\Nova\Fields\DateTime;
|
||||
use Laravel\Nova\Fields\Textarea;
|
||||
use Laravel\Nova\Fields\BelongsTo;
|
||||
use Laravel\Nova\Fields\MorphMany;
|
||||
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||
use App\Domain\Feeds\Models\Feed as ModelsFeed;
|
||||
use Ebess\AdvancedNovaMediaLibrary\Fields\Files;
|
||||
|
||||
class Feed extends Resource
|
||||
{
|
||||
/**
|
||||
* The model the resource corresponds to.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public static $model = ModelsFeed::class;
|
||||
public static $group = 'Content';
|
||||
|
||||
// /**
|
||||
// * The single value that should be used to represent the resource when being displayed.
|
||||
// *
|
||||
// * @var string
|
||||
// */
|
||||
// public static $title = 'title';
|
||||
|
||||
/**
|
||||
* Get the value that should be displayed to represent the resource.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
{
|
||||
if(empty($this->title)){
|
||||
return $this->id;
|
||||
}
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* The columns that should be searched.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $search = [
|
||||
'id', 'title', 'body'
|
||||
];
|
||||
|
||||
public static function indexQuery(NovaRequest $request, $query)
|
||||
{
|
||||
return $query->where('status', 1)->where('is_ads', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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(),
|
||||
Files::make('Media Preview', 'preview')->readonly(),
|
||||
Files::make('Media', 'common')->readonly(),
|
||||
Files::make('Media Paid', 'paid')->readonly(),
|
||||
Text::make('Title'),
|
||||
Text::make('Slug')->readonly(),
|
||||
Select::make('Type')->options([
|
||||
'images' => 'Изображение',
|
||||
'musics' => 'Аудио',
|
||||
'videos' => 'Видео',
|
||||
])->readonly()->displayUsingLabels(),
|
||||
Text::make('Price')->readonly(),
|
||||
Textarea::make('Body')->alwaysShow()->hideFromIndex(),
|
||||
HasMany::make('Comments'),
|
||||
HasMany::make('Complaints'),
|
||||
DateTime::make('Created At')->format('DD MMM YYYY'),
|
||||
DateTime::make('Updated At')->hideFromIndex(),
|
||||
// Select::make('Status')->options([
|
||||
// (string) StatusEnum::PENDING() => 'pending',
|
||||
// (string) StatusEnum::APPROVED() => 'approved',
|
||||
// (string) StatusEnum::BANNED() => 'banned',
|
||||
// (string) StatusEnum::EDITABLE() => 'editable',
|
||||
// ])->displayUsingLabels()->onlyOnIndex()->sortable(),
|
||||
|
||||
// Select::make('Status')->options([
|
||||
// (string) StatusEnum::APPROVED() => 'approved',
|
||||
// (string) StatusEnum::BANNED() => 'banned',
|
||||
// ])->displayUsingLabels()->hideFromIndex()->hideWhenCreating(),
|
||||
|
||||
// Textarea::make('Status Note')->hideWhenCreating(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user