%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/camillo/camillo-api-master/app/Nova/
Upload File :
Create Path :
Current File : /var/www/html/camillo/camillo-api-master/app/Nova/Notice.php

<?php

namespace App\Nova;

use App\Enums\NoticeStatusEnum;
use App\Enums\UsertypeEnum;
use Laravel\Nova\Fields\BelongsTo;
use Laravel\Nova\Fields\Boolean;
use Laravel\Nova\Fields\Date;
use Laravel\Nova\Fields\ID;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\Select;
use Laravel\Nova\Fields\Textarea;
use Laravel\Nova\Http\Requests\NovaRequest;
use Zingazzi\ItalianDateTime\ItalianDateTime as DateTime;

class Notice extends Resource
{
    /**
     * The model the resource corresponds to.
     *
     * @var string
     */
    public static $model = 'App\Models\Notice';

    /**
     * Indicates if the resource should be displayed in the sidebar.
     *
     * @var bool
     */
    public static $displayInNavigation = true;

    /**
     * The single value that should be used to represent the resource when being displayed.
     *
     * @var string
     */
    public static $title = 'content';

    public static function label()
    {
        return __('Emergency calls queue');
    }

    public static function singularLabel()
    {
        return __('Emergency calls queue');
    }

    /**
     * The columns that should be searched.
     *
     * @var array
     */
    public static $search = [
        'id', 'content', 'minor_id', 'classroom_id', 'individual_id', 'user_id', 'schoolyear_id', 'urgency', 'start_date', 'active'
    ];

    public static $with = [
        'institute', 'classroom', 'individual', 'minor'
    ];

    /**
     * Get the fields displayed by the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function fields(Request $request)
    {
        return [
            ID::make()->sortable()->canSee(function($request){
                return $request->user()->usertype->role === UsertypeEnum::ADMIN;
            }),

            Textarea::make(__('Content'), 'content')
                ->rules('required')
                ->sortable(),

            Select::make(__('Urgency'), 'urgency')->options([
                'High' => 'High',
                'Normal' => 'Normal',
                'Low' => 'Low'
            ])->rules('required'),

            DateTime::make(_('Start date'), 'start_date')->format('D-M-Y')
                ->rules('required'),

            DateTime::make(_('End date'), 'end_date')->format('D-M-Y')
                ->rules('required'),

         /*   DateTime::make(_('Scheduled at'), 'scheduled_at')->format('D-M-Y H:m:s')
                ->rules('required'),*/

            Select::make('Status', 'status')->options([
                NoticeStatusEnum::PENDING => __('Pending'),
                NoticeStatusEnum::UNDERWAY => __('Underway'),
                NoticeStatusEnum::HANDLED => __('Handled')
            ]),

            BelongsTo::make(__('Institute'), 'institute', Institute::class)
                ->rules('required')
                ->sortable()
                ->searchable(),

            BelongsTo::make(__('Classroom'), 'classroom', Classroom::class)
                ->rules('required')
                ->sortable()
                ->searchable(),

            BelongsTo::make(__('Individual'), 'individual', Individual::class)
                ->rules('required')
                ->sortable()
                ->searchable(),

            BelongsTo::make(__('Minor'), 'minor', Minor::class)
                ->rules('required')
                ->sortable()
                ->searchable(),

            BelongsTo::make(__('User'), 'user', User::class)
                ->rules('integer','exists:users,id')
                ->sortable()
                ->searchable(),

            BelongsTo::make(__('Schoolyear'), 'schoolyear', Schoolyear::class)
                ->rules('integer','exists:schoolyears,id')
                ->sortable()
                ->searchable(),

            Boolean::make(__('Active'), 'active')
        ];
    }

    /**
     * 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 [];
    }
}

Zerion Mini Shell 1.0