This commit is contained in:
f4ilji
2024-10-04 12:48:19 +05:00
parent 21a6e9073b
commit cebc584a14
303 changed files with 8224 additions and 2563 deletions
Vendored
BIN
View File
Binary file not shown.
+2 -3
View File
@@ -5,7 +5,6 @@
<sourceFolder url="file://$MODULE_DIR$/app" isTestSource="false" packagePrefix="App\" />
<sourceFolder url="file://$MODULE_DIR$/database/factories" isTestSource="false" packagePrefix="Database\Factories\" />
<sourceFolder url="file://$MODULE_DIR$/database/seeders" isTestSource="false" packagePrefix="Database\Seeders\" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" packagePrefix="Tests\" />
<excludeFolder url="file://$MODULE_DIR$/vendor/brick/math" />
<excludeFolder url="file://$MODULE_DIR$/vendor/carbonphp/carbon-doctrine-types" />
@@ -84,7 +83,6 @@
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/recursion-context" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/type" />
<excludeFolder url="file://$MODULE_DIR$/vendor/sebastian/version" />
<excludeFolder url="file://$MODULE_DIR$/vendor/spatie/laravel-permission" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/console" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/css-selector" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/deprecation-contracts" />
@@ -102,7 +100,6 @@
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-idn" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-intl-normalizer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-mbstring" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php72" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php80" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php83" />
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-uuid" />
@@ -174,6 +171,8 @@
<excludeFolder url="file://$MODULE_DIR$/vendor/pxlrbt/filament-excel" />
<excludeFolder url="file://$MODULE_DIR$/vendor/guava/filament-icon-picker" />
<excludeFolder url="file://$MODULE_DIR$/vendor/joshembling/image-optimizer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/bezhansalleh/filament-shield" />
<excludeFolder url="file://$MODULE_DIR$/vendor/spatie/laravel-permission" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
Generated
+2 -2
View File
@@ -43,7 +43,6 @@
<path value="$PROJECT_DIR$/vendor/psr/container" />
<path value="$PROJECT_DIR$/vendor/psr/http-client" />
<path value="$PROJECT_DIR$/vendor/psr/http-message" />
<path value="$PROJECT_DIR$/vendor/spatie/laravel-permission" />
<path value="$PROJECT_DIR$/vendor/psr/event-dispatcher" />
<path value="$PROJECT_DIR$/vendor/psr/log" />
<path value="$PROJECT_DIR$/vendor/fruitcake/php-cors" />
@@ -67,7 +66,6 @@
<path value="$PROJECT_DIR$/vendor/symfony/mailer" />
<path value="$PROJECT_DIR$/vendor/symfony/mime" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-ctype" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php72" />
<path value="$PROJECT_DIR$/vendor/symfony/error-handler" />
<path value="$PROJECT_DIR$/vendor/symfony/filesystem" />
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-intl-idn" />
@@ -184,6 +182,8 @@
<path value="$PROJECT_DIR$/vendor/pxlrbt/filament-excel" />
<path value="$PROJECT_DIR$/vendor/guava/filament-icon-picker" />
<path value="$PROJECT_DIR$/vendor/joshembling/image-optimizer" />
<path value="$PROJECT_DIR$/vendor/bezhansalleh/filament-shield" />
<path value="$PROJECT_DIR$/vendor/spatie/laravel-permission" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="8.1" />
+6
View File
@@ -56,6 +56,12 @@
<PhpSpecSuiteConfiguration>
<option name="myPath" value="$PROJECT_DIR$" />
</PhpSpecSuiteConfiguration>
<PhpSpecSuiteConfiguration>
<option name="myPath" value="$PROJECT_DIR$" />
</PhpSpecSuiteConfiguration>
<PhpSpecSuiteConfiguration>
<option name="myPath" value="$PROJECT_DIR$" />
</PhpSpecSuiteConfiguration>
</suites>
</component>
</project>
+28 -7
View File
@@ -31,6 +31,18 @@ use Symfony\Component\Finder\Finder;
class PostForm
{
private static function findSeoActive(array $data) : bool
{
$bool = false;
foreach ($data as $item) {
if ($item['data']['seo_active'] === true) {
$bool = true;
break;
}
}
return $bool;
}
public static function getForm(Form $form): Form
{
return $form
@@ -46,14 +58,16 @@ class PostForm
->live(onBlur: true)
->afterStateUpdated(function (string $operation, string|null $state, Forms\Set $set) {
$set('slug', Str::slug($state));
$set('seo.title', $state);
}),
TextInput::make('slug')->label('Slug')->unique(ignoreRecord: true)->readOnly()->required(),
]),
Select::make('status')->options([
'verification' => 'На рассмотрении',
'published' => 'Одобрено',
'rejected' => 'Отказано',
])->label('Статус')->required()->default(PostStatus::VERIFICATION),
Select::make('status')->options(PostStatus::class)
->label('Статус')->required()
->disableOptionWhen(fn (string $value): bool =>
$value == PostStatus::PUBLISHED->value && !auth()->user()->can('publish_post')
)
->default(PostStatus::VERIFICATION),
Select::make('category_id')
->options(Category::all()->pluck('title', 'id'))
->preload()
@@ -64,7 +78,7 @@ class PostForm
]),
Tabs\Tab::make('Содержание новости')
->schema([
\Filament\Forms\Components\Builder::make('content')->label('')->blocks([
Builder::make('content')->label('')->blocks([
Builder\Block::make('heading')->label('Заголовок')
->schema([
TextInput::make('id')->hidden()->integer()->default(rand(2335235,324634264263426)),
@@ -76,6 +90,13 @@ class PostForm
]),
Builder\Block::make('paragraph')->label('Текст')
->schema([
Toggle::make('seo_active')->label('Использовать блок как seo')
->live(onBlur: true)
->disabled(function ($state, Forms\Get $get) {
$data = $get('../../');
return self::findSeoActive($data) && !$state;
})
->dehydrated(),
RichEditor::make('content')
->toolbarButtons([
'blockquote',
@@ -90,7 +111,7 @@ class PostForm
'undo',
])
->label(''),
]),
])->live(onBlur: true),
Builder\Block::make('files')->label('Файлы')
->schema([
Forms\Components\Repeater::make('file')->schema([
@@ -2,15 +2,23 @@
namespace App\Filament\Resources;
use App\Enums\CustomFormStatus;
use App\Enums\PostStatus;
use App\Filament\Resources\AcademicJournalResource\Pages;
use App\Filament\Resources\AcademicJournalResource\RelationManagers;
use App\Filament\Resources\AcademicJournalResource\RelationManagers\JournalsRelationManager;
use App\Helpers\ByteConverter;
use App\Models\AcademicJournal;
use App\Models\Category;
use App\Models\CustomForm;
use App\Models\Page;
use App\Models\Post;
use Filament\Forms;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Tabs;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
@@ -18,7 +26,9 @@ use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Support\Carbon;
use Illuminate\Support\Str;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use Mohamedsabil83\FilamentFormsTinyeditor\Components\TinyEditor;
class AcademicJournalResource extends Resource
@@ -77,9 +87,259 @@ class AcademicJournalResource extends Resource
'underline',
'undo',
])
->label('')
->required(),
->label(''),
])->label('Текст'),
Builder\Block::make('files')
->schema([
Forms\Components\Repeater::make('file')->schema([
Hidden::make('expansion')->required(),
Hidden::make('size')->required(),
TextInput::make('title')
->required()
->maxLength(255)
->autofocus(),
FileUpload::make('path')
->required()
->getUploadedFileNameForStorageUsing(
fn (TemporaryUploadedFile $file): string =>
str(Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME) . '-' . Carbon::now()->timestamp ) . '.' . $file->getClientOriginalExtension())
)
->acceptedFileTypes([
'application/pdf',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/zip'
])
->maxSize(512000)
->disk('public')
->directory('files')
->downloadable()
->afterStateUpdated(function ($set, $state) {
$set('expansion', $state?->getClientOriginalExtension());
$set('size', ByteConverter::bytesToHuman($state?->getSize()));
})
->visibility('public')
]),
]),
Builder\Block::make('person')
->schema([
TextInput::make('name')
->label('Имя')
->required()
->maxLength(255),
FileUpload::make('photo')
->label('Фотография')
->image()
->disk('public')
->directory('images')
->imageEditor(),
Forms\Components\Repeater::make('info')->schema([
Forms\Components\Grid::make(2)->schema([
TextInput::make('column')
->required()
->maxLength(255),
TextInput::make('content')
->required()
->maxLength(255),
]),
])->minItems(1),
]),
Builder\Block::make('stepper')
->schema([
TextInput::make('step_name')
->label('Название шага')
->required()
->maxLength(255),
Forms\Components\Repeater::make('steps')->schema([
TextInput::make('title')
->required()
->maxLength(255)->columnSpanFull(),
RichEditor::make('content')->required(),
])->minItems(1),
]),
Builder\Block::make('tabs')
->schema([
Forms\Components\Repeater::make('tab')->schema([
TextInput::make('title')
->required()
->maxLength(255)->columnSpanFull(),
\Filament\Forms\Components\Builder::make('content')->label('')->blocks([
Builder\Block::make('heading')->label('Заголовок')
->schema([
TextInput::make('id')->hidden()->integer()->default(rand(2335235,324634264263426)),
TextInput::make('content')
->label('')
->live(onBlur: true)
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set, $get) {
}),
]),
Builder\Block::make('paragraph')
->schema([
RichEditor::make('content')
->toolbarButtons([
'blockquote',
'bold',
'bulletList',
'italic',
'link',
'orderedList',
'redo',
'strike',
'underline',
'undo',
])
->label(''),
])->label('Текст'),
Builder\Block::make('files')
->schema([
Forms\Components\Repeater::make('file')->schema([
TextInput::make('title')
->required()
->maxLength(255)
->autofocus(),
FileUpload::make('path')
->required()
->acceptedFileTypes([
'application/pdf',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/zip'
])
->maxSize(512000)
->disk('public')
->directory('files')
->downloadable()
->visibility('public')
]),
]),
Builder\Block::make('person')
->schema([
TextInput::make('name')
->label('Имя')
->required()
->maxLength(255),
FileUpload::make('photo')
->label('Фотография')
->image()
->disk('public')
->directory('images')
->imageEditor(),
Forms\Components\Repeater::make('info')->schema([
Forms\Components\Grid::make(2)->schema([
TextInput::make('column')
->required()
->maxLength(255),
TextInput::make('content')
->required()
->maxLength(255),
]),
])->minItems(1),
]),
Builder\Block::make('stepper')
->schema([
TextInput::make('step_name')
->label('Название шага')
->required()
->maxLength(255),
Forms\Components\Repeater::make('steps')->schema([
TextInput::make('title')
->required()
->maxLength(255)->columnSpanFull(),
RichEditor::make('content')->required(),
])->minItems(1),
]),
Builder\Block::make('images')
->schema([
FileUpload::make('url')
->label('Изображение(-я)')
->image()
->multiple()
->reorderable()
->maxFiles(5)
->disk('public')
->directory('images')
->imageEditor()
->required(),
TextInput::make('alt')
->label('Описание')
->placeholder('Необязяательно')
])->label('Слайдер изображений'),
Builder\Block::make('image')
->schema([
FileUpload::make('url')
->label('Изображение(-я)')
->image()
->multiple()
->reorderable()
->maxFiles(5)
->disk('public')
->directory('images')
->imageEditor()
->required(),
TextInput::make('alt')
->label('Описание')
->placeholder('Необязяательно')
])->label('Изображение'),
Builder\Block::make('video')
->schema([
TextInput::make('mime')->readOnly(),
TextInput::make('title')
->required()
->maxLength(255)
->autofocus(),
FileUpload::make('path')
->required()
->acceptedFileTypes([
'video/mp4',
'video/quicktime',
'video/x-msvideo',
'video/x-ms-wmv',
'video/avi',
'video/webm',
'video/ogg',
'video/3gpp',
'video/3gpp2',
'video/x-m4v',
])
->disk('public')
->directory('videos')
->afterStateUpdated(fn (callable $set, $state) => $set('mime', $state?->getMimeType())),
]),
Builder\Block::make('postsList')
->schema([
Forms\Components\Grid::make(2)->schema([
TextInput::make('count')
->label('Количество запией')
->integer(),
Select::make('category')
->options(Category::all()->pluck('title', 'id'))
]),
])->label('Список новостей'),
])
->collapsed()
->blockNumbers(false)
->collapsible()
->addActionLabel('Добавить новый блок'),
])->minItems(1),
]),
Builder\Block::make('images')
->schema([
FileUpload::make('url')
->label('Изображение(-я)')
->image()
->multiple()
->reorderable()
->maxFiles(5)
->disk('public')
->directory('images')
->imageEditor()
->required(),
TextInput::make('alt')
->label('Описание')
->placeholder('Необязяательно')
])->label('Слайдер изображений'),
Builder\Block::make('image')
->schema([
FileUpload::make('url')
@@ -95,26 +355,10 @@ class AcademicJournalResource extends Resource
TextInput::make('alt')
->label('Описание')
->placeholder('Необязяательно')
])->label('Изображение(-я)'),
])->label('Изображение'),
Builder\Block::make('video')
->schema([
Hidden::make('mime'),
TextInput::make('title')
->required()
->maxLength(255)
->autofocus(),
FileUpload::make('path')
->required()
->acceptedFileTypes(['video/mp4','video/ogg','video/webm'])
->maxSize(512000)
->disk('videos')
->visibility('public')
->afterStateUpdated(fn (callable $set, $state) => $set('mime', $state?->getMimeType())),
]),
Builder\Block::make('files')
->schema([
TextInput::make('mime')->readOnly(),
TextInput::make('title')
->required()
->maxLength(255)
@@ -122,22 +366,58 @@ class AcademicJournalResource extends Resource
FileUpload::make('path')
->required()
->acceptedFileTypes([
'application/pdf',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/zip'
'video/mp4',
'video/quicktime',
'video/x-msvideo',
'video/x-ms-wmv',
'video/avi',
'video/webm',
'video/ogg',
'video/3gpp',
'video/3gpp2',
'video/x-m4v',
])
->maxSize(512000)
->disk('public')
->directory('files')
->downloadable()
->visibility('public')
])
->directory('videos')
->afterStateUpdated(fn (callable $set, $state) => $set('mime', $state?->getMimeType())),
]),
Builder\Block::make('postsList')
->schema([
Forms\Components\Grid::make(2)->schema([
TextInput::make('count')
->label('Количество запией')
->integer(),
Select::make('category')
->options(Category::all()->pluck('title', 'id'))
]),
])->label('Список новостей'),
Builder\Block::make('postItem')
->schema([
Select::make('post')
->options(Post::query()->where('status', PostStatus::PUBLISHED)->pluck('title', 'id'))
->searchable()
->required(),
])->label('Новость'),
Builder\Block::make('pageItem')
->schema([
Select::make('page')
->options(Page::query()->where('title', '!=' , null)->where('is_visible', true)->pluck('title', 'id'))
->searchable()
->required(),
])->label('Страница'),
Builder\Block::make('customForm')
->schema([
Select::make('form')
->options(CustomForm::query()->where('status', CustomFormStatus::PUBLISHED)->pluck('title', 'form_id'))
->searchable()
->required(),
])->label('Форма'),
])
->collapsed()
->blockNumbers(false)
->collapsible()
->blockPickerColumns(3)
->blockPickerWidth('2xl')
->addActionLabel('Добавить новый блок'),
]),
Tabs\Tab::make('Редакция')
@@ -191,9 +471,259 @@ class AcademicJournalResource extends Resource
'underline',
'undo',
])
->label('')
->required()
->label(''),
])->label('Текст'),
Builder\Block::make('files')
->schema([
Forms\Components\Repeater::make('file')->schema([
Hidden::make('expansion')->required(),
Hidden::make('size')->required(),
TextInput::make('title')
->required()
->maxLength(255)
->autofocus(),
FileUpload::make('path')
->required()
->getUploadedFileNameForStorageUsing(
fn (TemporaryUploadedFile $file): string =>
str(Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME) . '-' . Carbon::now()->timestamp ) . '.' . $file->getClientOriginalExtension())
)
->acceptedFileTypes([
'application/pdf',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/zip'
])
->maxSize(512000)
->disk('public')
->directory('files')
->downloadable()
->afterStateUpdated(function ($set, $state) {
$set('expansion', $state?->getClientOriginalExtension());
$set('size', ByteConverter::bytesToHuman($state?->getSize()));
})
->visibility('public')
]),
]),
Builder\Block::make('person')
->schema([
TextInput::make('name')
->label('Имя')
->required()
->maxLength(255),
FileUpload::make('photo')
->label('Фотография')
->image()
->disk('public')
->directory('images')
->imageEditor(),
Forms\Components\Repeater::make('info')->schema([
Forms\Components\Grid::make(2)->schema([
TextInput::make('column')
->required()
->maxLength(255),
TextInput::make('content')
->required()
->maxLength(255),
]),
])->minItems(1),
]),
Builder\Block::make('stepper')
->schema([
TextInput::make('step_name')
->label('Название шага')
->required()
->maxLength(255),
Forms\Components\Repeater::make('steps')->schema([
TextInput::make('title')
->required()
->maxLength(255)->columnSpanFull(),
RichEditor::make('content')->required(),
])->minItems(1),
]),
Builder\Block::make('tabs')
->schema([
Forms\Components\Repeater::make('tab')->schema([
TextInput::make('title')
->required()
->maxLength(255)->columnSpanFull(),
\Filament\Forms\Components\Builder::make('content')->label('')->blocks([
Builder\Block::make('heading')->label('Заголовок')
->schema([
TextInput::make('id')->hidden()->integer()->default(rand(2335235,324634264263426)),
TextInput::make('content')
->label('')
->live(onBlur: true)
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set, $get) {
}),
]),
Builder\Block::make('paragraph')
->schema([
RichEditor::make('content')
->toolbarButtons([
'blockquote',
'bold',
'bulletList',
'italic',
'link',
'orderedList',
'redo',
'strike',
'underline',
'undo',
])
->label(''),
])->label('Текст'),
Builder\Block::make('files')
->schema([
Forms\Components\Repeater::make('file')->schema([
TextInput::make('title')
->required()
->maxLength(255)
->autofocus(),
FileUpload::make('path')
->required()
->acceptedFileTypes([
'application/pdf',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/zip'
])
->maxSize(512000)
->disk('public')
->directory('files')
->downloadable()
->visibility('public')
]),
]),
Builder\Block::make('person')
->schema([
TextInput::make('name')
->label('Имя')
->required()
->maxLength(255),
FileUpload::make('photo')
->label('Фотография')
->image()
->disk('public')
->directory('images')
->imageEditor(),
Forms\Components\Repeater::make('info')->schema([
Forms\Components\Grid::make(2)->schema([
TextInput::make('column')
->required()
->maxLength(255),
TextInput::make('content')
->required()
->maxLength(255),
]),
])->minItems(1),
]),
Builder\Block::make('stepper')
->schema([
TextInput::make('step_name')
->label('Название шага')
->required()
->maxLength(255),
Forms\Components\Repeater::make('steps')->schema([
TextInput::make('title')
->required()
->maxLength(255)->columnSpanFull(),
RichEditor::make('content')->required(),
])->minItems(1),
]),
Builder\Block::make('images')
->schema([
FileUpload::make('url')
->label('Изображение(-я)')
->image()
->multiple()
->reorderable()
->maxFiles(5)
->disk('public')
->directory('images')
->imageEditor()
->required(),
TextInput::make('alt')
->label('Описание')
->placeholder('Необязяательно')
])->label('Слайдер изображений'),
Builder\Block::make('image')
->schema([
FileUpload::make('url')
->label('Изображение(-я)')
->image()
->multiple()
->reorderable()
->maxFiles(5)
->disk('public')
->directory('images')
->imageEditor()
->required(),
TextInput::make('alt')
->label('Описание')
->placeholder('Необязяательно')
])->label('Изображение'),
Builder\Block::make('video')
->schema([
TextInput::make('mime')->readOnly(),
TextInput::make('title')
->required()
->maxLength(255)
->autofocus(),
FileUpload::make('path')
->required()
->acceptedFileTypes([
'video/mp4',
'video/quicktime',
'video/x-msvideo',
'video/x-ms-wmv',
'video/avi',
'video/webm',
'video/ogg',
'video/3gpp',
'video/3gpp2',
'video/x-m4v',
])
->disk('public')
->directory('videos')
->afterStateUpdated(fn (callable $set, $state) => $set('mime', $state?->getMimeType())),
]),
Builder\Block::make('postsList')
->schema([
Forms\Components\Grid::make(2)->schema([
TextInput::make('count')
->label('Количество запией')
->integer(),
Select::make('category')
->options(Category::all()->pluck('title', 'id'))
]),
])->label('Список новостей'),
])
->collapsed()
->blockNumbers(false)
->collapsible()
->addActionLabel('Добавить новый блок'),
])->minItems(1),
]),
Builder\Block::make('images')
->schema([
FileUpload::make('url')
->label('Изображение(-я)')
->image()
->multiple()
->reorderable()
->maxFiles(5)
->disk('public')
->directory('images')
->imageEditor()
->required(),
TextInput::make('alt')
->label('Описание')
->placeholder('Необязяательно')
])->label('Слайдер изображений'),
Builder\Block::make('image')
->schema([
FileUpload::make('url')
@@ -209,26 +739,10 @@ class AcademicJournalResource extends Resource
TextInput::make('alt')
->label('Описание')
->placeholder('Необязяательно')
])->label('Изображение(-я)'),
])->label('Изображение'),
Builder\Block::make('video')
->schema([
Hidden::make('mime'),
TextInput::make('title')
->required()
->maxLength(255)
->autofocus(),
FileUpload::make('path')
->required()
->acceptedFileTypes(['video/mp4','video/ogg','video/webm'])
->maxSize(512000)
->disk('videos')
->visibility('public')
->afterStateUpdated(fn (callable $set, $state) => $set('mime', $state?->getMimeType())),
]),
Builder\Block::make('files')
->schema([
TextInput::make('mime')->readOnly(),
TextInput::make('title')
->required()
->maxLength(255)
@@ -236,22 +750,58 @@ class AcademicJournalResource extends Resource
FileUpload::make('path')
->required()
->acceptedFileTypes([
'application/pdf',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'application/zip'
'video/mp4',
'video/quicktime',
'video/x-msvideo',
'video/x-ms-wmv',
'video/avi',
'video/webm',
'video/ogg',
'video/3gpp',
'video/3gpp2',
'video/x-m4v',
])
->maxSize(512000)
->disk('public')
->directory('files')
->downloadable()
->visibility('public')
])
->directory('videos')
->afterStateUpdated(fn (callable $set, $state) => $set('mime', $state?->getMimeType())),
]),
Builder\Block::make('postsList')
->schema([
Forms\Components\Grid::make(2)->schema([
TextInput::make('count')
->label('Количество запией')
->integer(),
Select::make('category')
->options(Category::all()->pluck('title', 'id'))
]),
])->label('Список новостей'),
Builder\Block::make('postItem')
->schema([
Select::make('post')
->options(Post::query()->where('status', PostStatus::PUBLISHED)->pluck('title', 'id'))
->searchable()
->required(),
])->label('Новость'),
Builder\Block::make('pageItem')
->schema([
Select::make('page')
->options(Page::query()->where('title', '!=' , null)->where('is_visible', true)->pluck('title', 'id'))
->searchable()
->required(),
])->label('Страница'),
Builder\Block::make('customForm')
->schema([
Select::make('form')
->options(CustomForm::query()->where('status', CustomFormStatus::PUBLISHED)->pluck('title', 'form_id'))
->searchable()
->required(),
])->label('Форма'),
])
->collapsed()
->blockNumbers(false)
->collapsible()
->blockPickerColumns(3)
->blockPickerWidth('2xl')
->addActionLabel('Добавить новый блок'),
]),
])->columnSpanFull()
@@ -2,9 +2,10 @@
namespace App\Filament\Resources;
use App\Filament\Resources\PermissionResource\Pages;
use App\Filament\Resources\PermissionResource\RelationManagers;
use App\Models\Permission;
use App\Filament\Resources\AcceptedInvitationResource\Pages;
use App\Filament\Resources\AcceptedInvitationResource\RelationManagers;
use App\Models\AcceptedInvitation;
use BezhanSalleh\FilamentShield\Contracts\HasShieldPermissions;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
@@ -13,15 +14,11 @@ use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
class PermissionResource extends Resource
class AcceptedInvitationResource extends Resource implements HasShieldPermissions
{
protected static ?string $model = Permission::class;
protected static ?string $model = AcceptedInvitation::class;
protected static ?string $navigationGroup = 'Settings';
protected static ?string $navigationIcon = 'heroicon-o-cursor-arrow-rays';
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
public static function form(Form $form): Form
{
@@ -60,9 +57,22 @@ class PermissionResource extends Resource
public static function getPages(): array
{
return [
'index' => Pages\ListPermissions::route('/'),
'create' => Pages\CreatePermission::route('/create'),
'edit' => Pages\EditPermission::route('/{record}/edit'),
'index' => Pages\ListAcceptedInvitations::route('/'),
'create' => Pages\CreateAcceptedInvitation::route('/create'),
'edit' => Pages\EditAcceptedInvitation::route('/{record}/edit'),
];
}
public static function getPermissionPrefixes(): array
{
return [
'view',
'view_any',
'create',
'update',
'delete',
'delete_any',
'invite'
];
}
}
@@ -0,0 +1,12 @@
<?php
namespace App\Filament\Resources\AcceptedInvitationResource\Pages;
use App\Filament\Resources\AcceptedInvitationResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreateAcceptedInvitation extends CreateRecord
{
protected static string $resource = AcceptedInvitationResource::class;
}
@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\AcceptedInvitationResource\Pages;
use App\Filament\Resources\AcceptedInvitationResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
class EditAcceptedInvitation extends EditRecord
{
protected static string $resource = AcceptedInvitationResource::class;
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
}
@@ -0,0 +1,58 @@
<?php
namespace App\Filament\Resources\AcceptedInvitationResource\Pages;
use App\Filament\Resources\AcceptedInvitationResource;
use App\Mail\InvitationMail;
use App\Models\Invitation;
use App\Models\User;
use BezhanSalleh\FilamentShield\Contracts\HasShieldPermissions;
use Filament\Actions;
use Filament\Forms\Components\TextInput;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\ListRecords;
use Illuminate\Support\Facades\Mail;
class ListAcceptedInvitations extends ListRecords
{
protected static string $resource = AcceptedInvitationResource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
Actions\Action::make('inviteUser')->label('Пригласить автора')
->form([
TextInput::make('email')
->email()
->label('Почта для письма')
->required()
])
->action(function ($data) {
$inv = User::query()
->where('email', $data['email'])
->first();
if ($inv) {
Notification::make()
->title('Данный пользователь существует в системе')
->danger()
->send();
} else {
$invitation = Invitation::create([
'email' => $data['email'],
'user_id' => auth()->user()->id,
]);
Mail::to($invitation->email)->send(new InvitationMail($invitation));
Notification::make('invitedSuccess')
->body('Пользователь приглашен')
->success()->send();
}
})->visible(auth()->user()->can('invite_accepted::invitation'))
];
}
}
@@ -39,8 +39,18 @@ class AdmissionCampaignResource extends Resource
Forms\Components\Section::make()->schema([
Forms\Components\Repeater::make('info')->schema([
Forms\Components\Select::make('edu_name')->options(LevelEducational::class),
Forms\Components\Grid::make(2)->schema([
Forms\Components\Section::make()->schema([
TextInput::make('total_programs')->label('Количество программ по набору')->integer()->required(),
]),
Forms\Components\Section::make('Места')->schema([
TextInput::make('och_count')->label('Количество мест (Очная форма)')->integer()->required(),
TextInput::make('zaoch_count')->label('Количество мест (Заочная форма)')->integer()->required(),
TextInput::make('budget_places')->label('Количество бюджетных мест')->integer()->required(),
TextInput::make('non_budget_places')->label('Количество платных мест')->integer()->required(),
]),
]),
])->columnSpanFull(),
]),
]);
}
@@ -22,7 +22,6 @@ class EditMainSection extends EditRecord
//
// protected function mutateFormDataBeforeSave(array $data): array
// {
// $this->subSection_ids = $data['subSection_ids'];
// unset($data['subSection_ids']);
//
// return $data;
@@ -30,6 +29,7 @@ class EditMainSection extends EditRecord
protected function afterSave(): void
{
$this->subSection_ids = SubSection::query()->where('main_section_id', '=', $this->record->id)->pluck('id')->toArray();
SubSection::query()->where('main_section_id', '=', $this->record->id)->update(['main_section_id' => NULL]);
SubSection::whereIn('id', $this->subSection_ids)->update(['main_section_id' => $this->record->id]);
$subSections = SubSection::query()->where('main_section_id', '=', $this->record->id)->get();
@@ -6,16 +6,18 @@ use App\Filament\Resources\PageResource;
use App\Models\SubSection;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
use Illuminate\Support\Str;
class CreatePage extends CreateRecord
{
protected static string $resource = PageResource::class;
protected array $seoData;
protected function mutateFormDataBeforeCreate(array $data): array
{
$subSection = SubSection::find($data['sub_section_id']);
if ($subSection == null) {
$data['path'] = $data['slug'];
} elseif($subSection->mainSection == null) {
@@ -25,23 +27,50 @@ class CreatePage extends CreateRecord
}
unset($data['sub_section_id']);
$this->seoData = $this->generateSeo($data);
$data['search_data'] = $this->generateSearchData($data['content']);
return $data;
}
protected function afterCreate(): void
{
$this->record->seo()->create($this->seoData);
}
private function generateSeo(array $data) : array
{
$title = $data['title'];
$rowData = $this->getFirstBlockByName('paragraph', $data['content']);
$description = strip_tags($rowData['data']['content']);
return [
'title' => $title,
'description' => Str::limit($description, 160),
];
}
private function getFirstBlockByName(string $name, array $content) : array|null
{
$data = null;
foreach ($content as $block) {
$data = ($block['type'] === $name) ? $block : null;
break;
}
return $data;
}
private function generateSearchData(array $data) : string
{
$result = "";
foreach ($data['content'] as $block) {
foreach ($data as $block) {
$result .= $this->getDataFromBlocks($block);
}
// Удаляем лишние пробелы и переносы строк
$result = preg_replace('/\s+/', ' ', $result);
$result = trim($result);
// Приводим текст к нижнему регистру
$data['search_data'] = strtolower($result);
return $data;
return strtolower($result);
}
private function getDataFromBlocks($block) : string
@@ -5,38 +5,25 @@ namespace App\Filament\Resources\PageResource\Pages;
use App\Filament\Resources\PageResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use Illuminate\Support\Str;
class EditPage extends EditRecord
{
protected static string $resource = PageResource::class;
protected array $seoData;
protected function mutateFormDataBeforeSave(array $data): array
{
$this->seoData = $this->generateSeo($data);
$result = "";
foreach ($data['content'] as $block) {
$result .= $this->getDataFromBlocks($block);
}
// Удаляем лишние пробелы и переносы строк
$result = preg_replace('/\s+/', ' ', $result);
$result = trim($result);
// Приводим текст к нижнему регистру
$data['search_data'] = strtolower($result);
$data['search_data'] = $this->generateSearchData($data['content']);
return $data;
}
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
protected function afterSave(): void
{
if ($this->record->is_registered == false) {
@@ -49,6 +36,52 @@ class EditPage extends EditRecord
}
}
$this->record->seo()->create($this->seoData);
}
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
private function generateSeo(array $data) : array
{
$title = $data['title'];
$rowData = $this->getFirstBlockByName('paragraph', $data['content']);
$description = strip_tags($rowData['data']['content']);
return [
'title' => $title,
'description' => Str::limit($description, 160),
];
}
private function getFirstBlockByName(string $name, array $content) : array|null
{
$data = null;
foreach ($content as $block) {
$data = ($block['type'] === $name) ? $block : null;
break;
}
return $data;
}
private function generateSearchData(array $data) : string
{
$result = "";
foreach ($data as $block) {
$result .= $this->getDataFromBlocks($block);
}
// Удаляем лишние пробелы и переносы строк
$result = preg_replace('/\s+/', ' ', $result);
$result = trim($result);
return strtolower($result);
}
private function getDataFromBlocks($block) : string
@@ -87,7 +120,6 @@ class EditPage extends EditRecord
}
return $data;
}
public function hasCombinedRelationManagerTabsWithContent(): bool
{
return true;
@@ -1,12 +0,0 @@
<?php
namespace App\Filament\Resources\PermissionResource\Pages;
use App\Filament\Resources\PermissionResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreatePermission extends CreateRecord
{
protected static string $resource = PermissionResource::class;
}
@@ -1,19 +0,0 @@
<?php
namespace App\Filament\Resources\PermissionResource\Pages;
use App\Filament\Resources\PermissionResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
class EditPermission extends EditRecord
{
protected static string $resource = PermissionResource::class;
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
}
@@ -1,19 +0,0 @@
<?php
namespace App\Filament\Resources\PermissionResource\Pages;
use App\Filament\Resources\PermissionResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListPermissions extends ListRecords
{
protected static string $resource = PermissionResource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}
+16 -1
View File
@@ -8,7 +8,9 @@ use App\Filament\Resources\PostResource\Pages;
use App\Models\Category;
use App\Models\Page;
use App\Models\Post;
use BezhanSalleh\FilamentShield\Contracts\HasShieldPermissions;
use Filament\Actions\DeleteAction;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\Checkbox;
@@ -36,7 +38,7 @@ use Illuminate\Support\Str;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use Mohamedsabil83\FilamentFormsTinyeditor\Components\TinyEditor;
class PostResource extends Resource
class PostResource extends Resource implements HasShieldPermissions
{
protected static ?string $model = Post::class;
@@ -92,6 +94,19 @@ class PostResource extends Resource
];
}
public static function getPermissionPrefixes(): array
{
return [
'view',
'view_any',
'create',
'update',
'delete',
'delete_any',
'publish'
];
}
@@ -2,7 +2,11 @@
namespace App\Filament\Resources\PostResource\Pages;
use App\Enums\PostStatus;
use App\Filament\Resources\PostResource;
use App\Models\Post;
use App\Models\User;
use Carbon\Carbon;
use Closure;
use Filament\Actions;
use Filament\Notifications\Actions\Action;
@@ -10,33 +14,94 @@ use Filament\Notifications\Notification;
use Filament\Resources\Pages\CreateRecord;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Messages\BroadcastMessage;
use Illuminate\Support\Str;
use PhpParser\Node\Expr\AssignOp\Mod;
class CreatePost extends CreateRecord
{
protected static string $resource = PostResource::class;
protected array $seoData;
protected function mutateFormDataBeforeCreate(array $data): array
{
$this->seoData = $this->generateSeo($data);
$data['preview_text'] = $this->setPreviewText($data);
$data['publish_at'] = $this->setPublishDateTime($data['status']);
$data['search_data'] = $this->generateSearchData($data['content']);
$data['reading_time'] = $this->calculateReadingTime($data['search_data']);
return $data;
}
protected function afterCreate(): void
{
$this->record->seo()->create($this->seoData);
$this->sendNotify($this->record, auth()->user());
}
private function generateSeo(array $data) : array
{
$title = $data['title'];
$rowData = $this->getBlockBySeoActiveState('paragraph', $data['content']);
$description = strip_tags($rowData['data']['content']);
$image = ($data['preview'] !== null) ? $data['preview'] : null;
return [
'title' => $title,
'description' => Str::limit($description, 160),
'image' => $image,
];
}
private function setPreviewText(array $data) : string
{
$rowData = $this->getBlockBySeoActiveState('paragraph', $data['content']);
$preview_text = strip_tags($rowData['data']['content']);
return Str::limit($preview_text, 160);
}
private function generateSearchData(array $data) : string
{
$result = "";
foreach ($data['content'] as $block) {
foreach ($data as $block) {
$result .= $this->getDataFromBlocks($block);
}
// Удаляем лишние пробелы и переносы строк
$result = preg_replace('/\s+/', ' ', $result);
$result = trim($result);
// Приводим текст к нижнему регистру
$data['search_data'] = strtolower($result);
return strtolower($result);
}
private function getFirstBlockByName(string $name, array $content) : array|null
{
$data = null;
foreach ($content as $block) {
$data = ($block['type'] === $name) ? $block : null;
break;
}
return $data;
}
protected function afterCreate(): void
{
$recipient = auth()->user();
private function getBlockBySeoActiveState(string $name, array $content) : array|null
{
$data = [];
foreach ($content as $block) {
if ($block['type'] === $name) {
$data[] = $block;
}
}
$block = null;
foreach ($data as $item) {
if ($item['data']['seo_active'] === true) {
$block = $item;
}
}
return $block;
}
private function sendNotify($post, $recipient) : void
{
Notification::make()
->title('Новость на проверку')
->body('Новая запись была создана!')
@@ -45,13 +110,17 @@ class CreatePost extends CreateRecord
->label('Проверить')
->button()
->markAsRead()
->url(PostResource::getUrl('edit', ['record' => $this->record])),
->url(PostResource::getUrl('edit', ['record' => $post])),
])
->sendToDatabase($recipient);
])->sendToDatabase($recipient);
}
private function setPublishDateTime(PostStatus $status) : Carbon|null
{
if ($status !== PostStatus::PUBLISHED) {
return null;
}
return Carbon::now();
}
private function calculateReadingTime(string $text): int
{
@@ -73,7 +142,6 @@ class CreatePost extends CreateRecord
return $readingTime;
}
protected function convertDataToHtml($blocks) {
$convertedHtml = "";
foreach ($blocks as $block) {
@@ -126,7 +194,6 @@ class CreatePost extends CreateRecord
}
return $convertedHtml;
}
private function getDataFromBlocks($block) : string
{
$data = "";
@@ -2,32 +2,83 @@
namespace App\Filament\Resources\PostResource\Pages;
use App\Enums\PostStatus;
use App\Filament\Resources\PostResource;
use Carbon\Carbon;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use Illuminate\Support\Str;
class EditPost extends EditRecord
{
protected static string $resource = PostResource::class;
protected array $seoData;
protected function mutateFormDataBeforeSave(array $data): array
{
$result = "";
foreach ($data['content'] as $block) {
$result .= $this->getDataFromBlocks($block);
}
// Удаляем лишние пробелы и переносы строк
$result = preg_replace('/\s+/', ' ', $result);
$result = trim($result);
// Приводим текст к нижнему регистру
$data['search_data'] = strtolower($result);
$this->seoData = $this->generateSeo($data);
$data['preview_text'] = $this->setPreviewText($data);
$data['publish_at'] = $this->setPublishDateTime($data['status'], $this->record->publish_at);
$data['search_data'] = $this->generateSearchData($data['content']);
$data['reading_time'] = $this->calculateReadingTime($data['search_data']);
return $data;
}
protected function afterSave(): void
{
$this->record->seo()->update($this->seoData);
}
private function setPreviewText(array $data) : string
{
$rowData = $this->getBlockBySeoActiveState('paragraph', $data['content']);
$preview_text = strip_tags($rowData['data']['content']);
return Str::limit($preview_text, 160);
}
private function getBlockBySeoActiveState(string $name, array $content) : array|null
{
$data = [];
foreach ($content as $block) {
if ($block['type'] === $name) {
$data[] = $block;
}
}
$block = null;
foreach ($data as $item) {
if ($item['data']['seo_active'] === true) {
$block = $item;
}
}
return $block;
}
private function generateSeo(array $data) : array
{
$title = $data['title'];
$rowData = $this->getFirstBlockByName('paragraph', $data['content']);
$description = strip_tags($rowData['data']['content']);
$image = ($this->record->preview !== null) ? $this->record->preview : null;
return [
'title' => $title,
'description' => Str::limit($description, 160),
'image' => $image,
];
}
private function setPublishDateTime($status, $publish_at)
{
if ($publish_at !== null) {
return $publish_at;
}
return PostStatus::tryFrom($status) === PostStatus::PUBLISHED ? Carbon::now() : null;
}
private function getDataFromBlocks($block) : string
{
$data = "";
@@ -65,6 +116,51 @@ class EditPost extends EditRecord
return $data;
}
private function calculateReadingTime(string $text): int
{
// Calculate the number of words in the text
$wordCount = str_word_count($text,0,"АаБбВвГгДдЕеЁёЖжЗзИиЙйКкЛлМмНнОоПпРрСсТтУуФфХхЦцЧчШшЩщЪъЫыЬьЭэЮюЯя");
// Calculate the average reading speed in words per minute
$wordsPerMinute = 120; // You can adjust this value based on your desired reading speed
// Calculate the reading time in minutes
$readingTime = $wordCount / $wordsPerMinute;
// Round the reading time to the nearest integer
$readingTime = round($readingTime);
return $readingTime;
}
private function generateSearchData(array $data) : string
{
$result = "";
foreach ($data as $block) {
$result .= $this->getDataFromBlocks($block);
}
// Удаляем лишние пробелы и переносы строк
$result = preg_replace('/\s+/', ' ', $result);
$result = trim($result);
return strtolower($result);
}
private function getFirstBlockByName(string $name, array $content) : array|null
{
$data = null;
foreach ($content as $block) {
$data = ($block['type'] === $name) ? $block : null;
break;
}
return $data;
}
protected function getHeaderActions(): array
@@ -1,164 +0,0 @@
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\RedactorPostResource\Pages;
use App\Models\Category;
use App\Models\Post;
use Filament\Actions\DeleteAction;
use Filament\Forms;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\SpatieTagsInput;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Filament\Infolists\Components\Card;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Support\Str;
class RedactorPostResource extends Resource
{
protected static ?string $model = Post::class;
protected static ?string $navigationGroup = "Для редактора";
protected static ?string $pluralLabel = 'Новости';
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
public static function form(Form $form): Form
{
return $form
->schema([
Section::make()
->schema([
Forms\Components\Grid::make(2)->schema([
TextInput::make('title')->label('Заголовок')->required()
->live(onBlur: true)
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
$set('slug', Str::slug($state));
}),
TextInput::make('slug')->label('Slug')->unique(ignoreRecord: true)->readOnly()->required(),
]),
Section::make()->schema([
\Filament\Forms\Components\Builder::make('content')->label('Контент')->blocks([
Builder\Block::make('heading')
->schema([
TextInput::make('content')
->label('Heading')
->required(),
Select::make('level')
->options([
'h1' => 'Heading 1',
'h2' => 'Heading 2',
'h3' => 'Heading 3',
'h4' => 'Heading 4',
'h5' => 'Heading 5',
'h6' => 'Heading 6',
])
->required(),
])
->columns(2),
Builder\Block::make('paragraph')
->schema([
RichEditor::make('content')
->label('Paragraph')
->required()
]),
Builder\Block::make('image')
->schema([
FileUpload::make('url')
->label('Image')
->image()
->required(),
TextInput::make('alt')
->label('Alt text')
->required(),
]),
Builder\Block::make('video')
->schema([
Hidden::make('mime'),
TextInput::make('title')
->required()
->maxLength(255)
->autofocus(),
FileUpload::make('path')
->required()
->acceptedFileTypes(['video/mp4','video/ogg','video/webm'])
->maxSize(512000)
->disk('videos')
->visibility('public')
->afterStateUpdated(fn (callable $set, $state) => $set('mime', $state?->getMimeType())),
])
]),
]),
Select::make('status')->options([
'verification' => 'На рассмотрении',
'published' => 'Одобрено',
'rejected' => 'Отказано',
])->label('Статус')->required()->default('verification'),
Forms\Components\TagsInput::make('authors')
->label('Авторы')->placeholder('Добавить автора'),
SpatieTagsInput::make('tags')
->label('Тэги'),
Select::make('category_id')
->options(Category::all()->pluck('title', 'id'))
->preload()
->label('Категория'),
FileUpload::make('preview')->label('Превью новости')->image()->imageEditor(),
TextInput::make('search_data')->hidden(),
])
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('id'),
Tables\Columns\TextColumn::make('title')->label('Заголовок')
->searchable(),
Tables\Columns\TextColumn::make('status')->label('Статус')->badge()
])->defaultSort('created_at', 'desc')
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListRedactorPosts::route('/'),
'create' => Pages\CreateRedactorPost::route('/create'),
'edit' => Pages\EditRedactorPost::route('/{record}/edit'),
];
}
}
@@ -1,12 +0,0 @@
<?php
namespace App\Filament\Resources\RedactorPostResource\Pages;
use App\Filament\Resources\RedactorPostResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreateRedactorPost extends CreateRecord
{
protected static string $resource = RedactorPostResource::class;
}
@@ -1,24 +0,0 @@
<?php
namespace App\Filament\Resources\RedactorPostResource\Pages;
use App\Filament\Resources\RedactorPostResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
class EditRedactorPost extends EditRecord
{
protected static string $resource = RedactorPostResource::class;
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('index');
}
}
@@ -1,46 +0,0 @@
<?php
namespace App\Filament\Resources\RedactorPostResource\Pages;
use App\Enums\PostStatus;
use App\Filament\Resources\PostResource;
use App\Filament\Resources\RedactorPostResource;
use App\Models\Post;
use Filament\Actions;
use Filament\Resources\Components\Tab;
use Filament\Resources\Pages\ListRecords;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\DB;
class ListRedactorPosts extends ListRecords
{
protected static string $resource = RedactorPostResource::class;
public \Illuminate\Support\Collection $postsByStatuses;
public function __construct()
{
$this->postsByStatuses = Post::select('status', DB::raw('count(*) as post_count'))
->groupBy('status')
->pluck('post_count', 'status');
}
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
public function getTabs(): array
{
return [
'status' => Tab::make('Новости на рассмотрении')->modifyQueryUsing(function (Builder $query) {
$query->where('status', '=', PostStatus::VERIFICATION->value);
})->badge($this->postsByStatuses[PostStatus::VERIFICATION->value] ?? '0'),
'All' => Tab::make('Все новости'),
];
}
}
-66
View File
@@ -1,66 +0,0 @@
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\RoleResource\Pages;
use App\Filament\Resources\RoleResource\RelationManagers;
use App\Models\Role;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
class RoleResource extends Resource
{
protected static ?string $model = Role::class;
protected static ?string $navigationGroup = 'Settings';
protected static ?string $navigationIcon = 'heroicon-o-shield-check';
public static function form(Form $form): Form
{
return $form
->schema([
//
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
//
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListRoles::route('/'),
'create' => Pages\CreateRole::route('/create'),
'edit' => Pages\EditRole::route('/{record}/edit'),
];
}
}
@@ -1,12 +0,0 @@
<?php
namespace App\Filament\Resources\RoleResource\Pages;
use App\Filament\Resources\RoleResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;
class CreateRole extends CreateRecord
{
protected static string $resource = RoleResource::class;
}
@@ -1,19 +0,0 @@
<?php
namespace App\Filament\Resources\RoleResource\Pages;
use App\Filament\Resources\RoleResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
class EditRole extends EditRecord
{
protected static string $resource = RoleResource::class;
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
}
@@ -1,19 +0,0 @@
<?php
namespace App\Filament\Resources\RoleResource\Pages;
use App\Filament\Resources\RoleResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListRoles extends ListRecords
{
protected static string $resource = RoleResource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}
+84 -60
View File
@@ -4,6 +4,7 @@ namespace App\Filament\Resources;
use App\Filament\Resources\ScheduleResource\Pages;
use App\Filament\Resources\ScheduleResource\RelationManagers;
use App\Helpers\ByteConverter;
use App\Models\Category;
use App\Models\EducationalGroup;
use App\Models\Schedule;
@@ -26,8 +27,10 @@ use Filament\Tables;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Support\Carbon;
use Illuminate\Support\Str;
use Livewire\Component;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use Livewire\Livewire;
class ScheduleResource extends Resource
@@ -58,72 +61,93 @@ class ScheduleResource extends Resource
Select::make('educational_group_id')->options(EducationalGroup::all()->pluck('title', 'id'))
->live()
->label('Выбрать группу')
->afterStateUpdated(function (string|null $state, Forms\Set $set, Get $get) {
if (!empty($state)) {
$set('title', EducationalGroup::query()->where('id', $get('educational_group_id'))->first()->title);
}
})
->required(),
TextInput::make('title')
->live()
// TextInput::make('title')
// ->live()
// ->label('Заголовок')->required(),
->label('Заголовок')->required(),
Select::make('type')->options([
'schedule' => 'Обычное расписание',
'interval' => 'Временное расписание',
'exam' => 'Промежуточная аттестация',
])->label('Тип расписания')->required()->live(),
// Select::make('type')->options([
// 'schedule' => 'Обычное расписание',
// 'interval' => 'Временное расписание',
// 'exam' => 'Промежуточная аттестация',
// ])->label('Тип расписания')->required()->live(),
Forms\Components\Toggle::make('is_zaoch')->label('Очная|Заочная')->inline(false),
]),
Forms\Components\Repeater::make('days')->label('')->schema([
Forms\Components\Repeater::make('form')->label('')->schema([
Forms\Components\Repeater::make('weeks')->label('')->schema([
Forms\Components\Repeater::make('lesson_info')->label('')->schema([
TextInput::make('title')->label('Название-пары'),
TextInput::make('teacher')->label('Преподаватель'),
TextInput::make('studyRoom')->label('Кабинет')
])->live()->maxItems(2)->collapsed()->addActionLabel('Добавить подгруппу')->columns(3)
->itemLabel(function (Get $get, $state) {
static $count = 1;
if (count($get('lesson_info')) === 1) {
return "Общая группа";
} else {
$nmb = $count++ % 2 == 0 ? 2 : 1;
return "Подгруппа " . $nmb; }
}),
])->maxItems(2)->addActionLabel('Добавить четную/нечетную неделю')
->itemLabel(function (Get $get) {
static $position = 0;
if (count($get('weeks')) === 1) {
return "Общая неделя";
} else {
$nmb = $position++ % 2 == 0 ? 0 : 1;
return self::$typeWeek[$nmb] . " неделя";
}
// Forms\Components\Repeater::make('days')->label('')->schema([
// Forms\Components\Repeater::make('form')->label('')->schema([
// Forms\Components\Repeater::make('weeks')->label('')->schema([
// Forms\Components\Repeater::make('lesson_info')->label('')->schema([
// TextInput::make('title')->label('Название-пары'),
// TextInput::make('teacher')->label('Преподаватель'),
// TextInput::make('studyRoom')->label('Кабинет')
// ])->live()->maxItems(2)->collapsed()->addActionLabel('Добавить подгруппу')->columns(3)
// ->itemLabel(function (Get $get, $state) {
// static $count = 1;
// if (count($get('lesson_info')) === 1) {
// return "Общая группа";
// } else {
// $nmb = $count++ % 2 == 0 ? 2 : 1;
// return "Подгруппа " . $nmb; }
// }),
// ])->maxItems(2)->addActionLabel('Добавить четную/нечетную неделю')
// ->itemLabel(function (Get $get) {
// static $position = 0;
// if (count($get('weeks')) === 1) {
// return "Общая неделя";
// } else {
// $nmb = $position++ % 2 == 0 ? 0 : 1;
// return self::$typeWeek[$nmb] . " неделя";
// }
// })
// ->collapsed()
// ])
// ->maxItems(5)
// ->itemLabel(function (Get $get) {
// static $count = 0;
// $maxCount = count($get('form'));
// $count = ($count++ <= $maxCount) ? $count : 1;
// return "Пара #" . $count;
// })
// ->addActionLabel('Добавить пару'),
// ])->maxItems(6)->minItems(1)->itemLabel(function ($state) {
// static $position = 0;
// return self::$weekDays[$position++];
// })->addActionLabel('Добавить день недели')->collapsed()->defaultItems(6)->hidden(function (callable $get) {
// if ($get('type') === 'schedule' || $get('type') === 'interval') {
// return false;
// } else {
// return true;
// }
// }),
]),
Section::make()
->schema([
Forms\Components\Repeater::make('file')->schema([
TextInput::make('title')
->required()
->maxLength(255)
->autofocus(),
FileUpload::make('path')
->required()
->getUploadedFileNameForStorageUsing(
fn (TemporaryUploadedFile $file): string =>
str(Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME) . '-' . Carbon::now()->timestamp ) . '.' . $file->getClientOriginalExtension())
)
->acceptedFileTypes([
'application/pdf',
])
->maxSize(512000)
->disk('public')
->directory('files')
->downloadable()
->afterStateUpdated(function ($set, $state) {
$set('title', pathinfo($state?->getClientOriginalName(), PATHINFO_FILENAME));
})
->collapsed()
])
->maxItems(5)
->itemLabel(function (Get $get) {
static $count = 0;
$maxCount = count($get('form'));
$count = ($count++ <= $maxCount) ? $count : 1;
return "Пара #" . $count;
})
->addActionLabel('Добавить пару'),
])->maxItems(6)->minItems(1)->itemLabel(function ($state) {
static $position = 0;
return self::$weekDays[$position++];
})->addActionLabel('Добавить день недели')->collapsed()->defaultItems(6)->hidden(function (callable $get) {
if ($get('type') === 'schedule' || $get('type') === 'interval') {
return false;
} else {
return true;
}
}),
])
->visibility('public')
]),
])
]);
}
@@ -12,7 +12,6 @@ class CreateSchedule extends CreateRecord
protected function mutateFormDataBeforeCreate(array $data): array
{
dd($data);
return $data;
}
@@ -12,37 +12,4 @@ use Filament\Resources\Pages\CreateRecord;
class CreateSubSection extends CreateRecord
{
protected static string $resource = SubSectionResource::class;
protected array $page_ids;
protected function mutateFormDataBeforeCreate(array $data): array
{
$this->page_ids = $data['page_ids'];
unset($data['page_ids']);
return $data;
}
protected function afterCreate(): void
{
if ($this->page_ids != null) {
Page::whereIn('id', $this->page_ids)->update(['sub_section_id' => $this->record->id]);
$pages = Page::where('is_url', '=', false)->where('sub_section_id', '=', $this->record->id)->get();
if (!$pages->isEmpty()) {
$mainSectionSlug = ($pages[0]->section->mainSection) ? $pages[0]->section->mainSection->slug : '';
foreach ($pages as $page) {
if ($page->is_registered != true) {
$page->update(['path' => $page->path = $mainSectionSlug . '/' . $this->record->slug . '/' . $page->slug]);
}
}
}
}
}
}
+15 -2
View File
@@ -5,6 +5,7 @@ namespace App\Filament\Resources;
use App\Filament\Resources\UserResource\Pages;
use App\Filament\Resources\UserResource\RelationManagers;
use App\Models\User;
use BezhanSalleh\FilamentShield\Contracts\HasShieldPermissions;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
@@ -13,7 +14,7 @@ use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
class UserResource extends Resource
class UserResource extends Resource implements HasShieldPermissions
{
protected static ?string $model = User::class;
@@ -40,7 +41,6 @@ class UserResource extends Resource
->password()
->required(fn (string $context): bool => $context === 'create')
->dehydrated(fn ($state) => filled($state))
->maxLength(255),
]);
}
@@ -93,4 +93,17 @@ class UserResource extends Resource
'edit' => Pages\EditUser::route('/{record}/edit'),
];
}
public static function getPermissionPrefixes(): array
{
return [
'view',
'view_any',
'create',
'update',
'delete',
'delete_any',
'invite'
];
}
}
@@ -3,8 +3,14 @@
namespace App\Filament\Resources\UserResource\Pages;
use App\Filament\Resources\UserResource;
use App\Mail\InvitationMail;
use App\Models\Invitation;
use App\Models\User;
use Filament\Actions;
use Filament\Forms\Components\TextInput;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\ListRecords;
use Illuminate\Support\Facades\Mail;
class ListUsers extends ListRecords
{
@@ -14,6 +20,38 @@ class ListUsers extends ListRecords
{
return [
Actions\CreateAction::make(),
Actions\Action::make('inviteUser')->label('Пригласить автора')
->form([
TextInput::make('email')
->email()
->label('Почта для письма')
->required()
])
->action(function ($data) {
$inv = User::query()
->where('email', $data['email'])
->first();
if ($inv) {
Notification::make()
->title('Данный пользователь существует в системе')
->danger()
->send();
} else {
$invitation = Invitation::create([
'email' => $data['email'],
'user_id' => auth()->user()->id,
]);
Mail::to($invitation->email)->send(new InvitationMail($invitation));
Notification::make('invitedSuccess')
->body('Пользователь приглашен')
->success()->send();
}
})->visible(auth()->user()->can('invite_user'))
];
}
}
@@ -105,8 +105,7 @@ class ClientEventController extends Controller
->orderBy('event_date_start')
->get();
// Извлекаем уникальные даты из событий
return $events->map(function ($event) {
$mappingDates = $events->map(function ($event) {
$date = new DateTime($event->event_date_start);
return [
'day' => $date->format('j'),
@@ -119,10 +118,15 @@ class ClientEventController extends Controller
})
->map(function ($group, $month) {
return [
'month' => $this->getMonthNameRussian((int)$month),
'events' => $group->toArray()
"month" => $this->getMonthNameRussian((int)$month),
"events" => $group->toArray()
];
});
})
->sortKeys() // Сортируем ключи по возрастанию
->values(); // Получаем массив без ключей
// Извлекаем уникальные даты из событий
return $mappingDates;
}
private function getFilters(): array
@@ -52,7 +52,8 @@ class ClientPostController extends Controller
$slugsArray = explode(',', $slugs);
return $query->withAnyTags($slugsArray);
})
->orderBy('id', request()->input('sort', 'desc'))
->orderBy('publish_at', request()->input('sort', 'desc'))
->paginate(6)
->withQueryString());
@@ -100,7 +101,8 @@ class ClientPostController extends Controller
return Inertia::render('Client/Posts/Index', compact('filters', 'posts', 'categories', 'tags'));
}
public function show($slug)
public function show(Request $request, $slug)
{
$post = new PostResource(Post::where('slug', $slug)->firstOrFail());
return Inertia::render('Client/Posts/Show', compact('post'));
@@ -19,16 +19,13 @@ class ClientScheduleController extends Controller
if (request()->filled('search')) {
$educationalGroups = ClientEducationalGroupResource::collection(EducationalGroup::query()
->has('schedules')
->whereHas('schedules', function ($q) {
$q->when(request()->input('search'), function ($query, $search) {
$query->whereRaw('LOWER(title) like ?', ["%".strtolower($search)."%"]);
});
->when(request()->input('search'), function ($query, $search) {
$query->whereRaw('LOWER(title) like ?', ["%".strtolower($search)."%"]);
})
->with('schedules')
->orderBy('title')
->get());
}
$searchRequest = request()->input('search');
return Inertia::render('Client/Schedules/Index', compact('educationalGroups', 'searchRequest'));
@@ -20,7 +20,7 @@ class ClientWidgetPostController extends Controller
$query->where('category_id', $category_id);
})
->with('category')
->orderBy('created_at', 'desc')
->orderBy('publish_at', 'desc')
->take(request()->input('count', 5))
->get());
}
+33 -7
View File
@@ -2,6 +2,9 @@
namespace App\Http\Controllers;
use App\Enums\EducationalProgramStatus;
use App\Enums\LevelEducational;
use App\Enums\PostStatus;
use App\Http\Resources\AdditionalEducationResource;
use App\Http\Resources\ClientMainSliderResource;
use App\Http\Resources\ClientNavigationResource;
@@ -12,6 +15,8 @@ use App\Http\Resources\PostThumbnailResource;
use App\Models\AdditionalEducation;
use App\Models\AdditionalEducationCategory;
use App\Models\AdmissionCampaign;
use App\Models\DirectionStudy;
use App\Models\EducationalProgram;
use App\Models\Event;
use App\Models\MainSection;
use App\Models\MainSlider;
@@ -19,6 +24,7 @@ use App\Models\Post;
use App\Services\Filament\Icon\ArrayToCollectionService;
use DateTime;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Route;
use Inertia\Inertia;
@@ -27,23 +33,43 @@ class MainController extends Controller
public function index()
{
$additional_educations = [
'educations_count' => AdditionalEducation::where('is_active', true)->count(),
'categories_count' => AdditionalEducationCategory::where('is_active', true)->count()
$info = AdmissionCampaign::get()->first()->info ?? [];
$admissionCampaign = collect($info)->reduce(function ($carry, $a) {
$lvl = LevelEducational::from((int)$a['edu_name'])->name;
$carry[$lvl] = [
'total_programs' => $a['total_programs'],
'places' => [
'och_count' => $a['och_count'],
'zaoch_count' => $a['zaoch_count'],
'budget_places' => $a['budget_places'],
'non_budget_places' => $a['non_budget_places']
],
];
return $carry;
}, []);
$educations = [
'admission_campaign' => $admissionCampaign,
'additional_education' => [
'educations_count' => AdditionalEducation::where('is_active', true)->count(),
'categories_count' => AdditionalEducationCategory::where('is_active', true)->count()
],
];
$today = new DateTime();
$event_date_start = $today->format('Y-m-d');
$sliders = ClientMainSliderResource::collection(MainSlider::query()->where('is_active', true)->orderBy('sort', 'asc')->get());
$posts = PostThumbnailResource::collection(Post::query()
->select('title', 'slug', 'authors', 'category_id', 'preview', 'search_data', 'created_at')
->select('title', 'slug', 'authors', 'preview_text', 'category_id', 'preview', 'search_data', 'created_at')
->with('category')
->where('status', '=', 'published')
->orderBy('id', 'desc')->limit(3)
->where('status', '=', PostStatus::PUBLISHED)
->orderBy('publish_at', 'desc')->limit(3)
->get());
$events = EventThumbnailResource::collection(Event::query()
->select('title', 'slug', 'event_date_start', 'address', 'is_online', 'category_id')
->where('event_date_start', '>=', $event_date_start)
->orderBy('event_date_start', 'asc')->limit(3)->get());
return Inertia::render('Main', compact('posts', 'events', 'sliders', 'additional_educations'));
return Inertia::render('Main', compact('posts', 'events', 'sliders', 'educations'));
}
}
+1 -1
View File
@@ -30,7 +30,7 @@ class PostController extends Controller
->when(request()->input('search'), function ($query, $search) {
$query->where('title', 'like', "%{$search}%");
})
->orderBy('id', 'desc')
->orderBy('publish_at', 'desc')
->paginate(request()->input('perPage', 9))
->withQueryString());
$filters = [
+62 -5
View File
@@ -16,8 +16,9 @@ use App\Models\EducationalProgram;
use App\Models\Event;
use App\Models\Page;
use App\Models\Post;
use Filament\Notifications\Collection;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Date;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Str;
@@ -33,9 +34,11 @@ class SearchController extends Controller
'searchRes' => null,
]);
}
$results = Search::new()
->add(Post::where('status', '=', 'published'), ['title', 'search_data'])
->add(Page::where('searchable', '=', true), ['title', 'search_data'])
->add(Page::with('section')->where('searchable', '=', true), ['title', 'search_data'])
->add(Event::where('event_date_start', '>', Date::now()), 'title')
->add(AdditionalEducation::where('is_active', '=', true), 'title')
->add(EducationalGroup::with('schedules'), 'title')
@@ -46,6 +49,7 @@ class SearchController extends Controller
->ignoreCase(true)
->search($req);
// Преобразуем результаты в коллекцию и мапируем их
$resources = collect($results)->map(function ($result) {
if ($result instanceof Post) {
return new PostSearchResource($result);
@@ -67,13 +71,30 @@ class SearchController extends Controller
}
});
$limitedRes = $resources->take(10);
$result_type = $this->getCategoriesSearchResult($resources);
if ($request->query('category')) {
$resources = $this->sortResourcesByCategory($resources, $request->query('category'));
}
$paginate_data = $this->createPaginate($resources, $request, 10);
$sortedData = $this->sortByType($paginate_data['paginator'], $req);
return response()->json([
'searchRes' => $this->sortByType($limitedRes, $req),
'searchRes' => $sortedData,
'result_type' => $result_type,
'selectedCategory' => ($request->query('category') !== null) ? $request->query('category') : null,
'paginate' => [
'current_page' => $paginate_data['paginator']->currentPage(),
'last_page' => $paginate_data['paginator']->lastPage(),
'total' => $paginate_data['paginator']->total(),
'next_page' => $paginate_data['next_page'],
'prev_page' => $paginate_data['prev_page'],
]
]);
}
private function sortByType(object $data, string $searchRequest): array
{
$sortedData = [];
@@ -105,5 +126,41 @@ class SearchController extends Controller
return $matches;
}
private function sortResourcesByCategory(Collection $resources, string $category) : Collection
{
if ($category === "All") {
$data = $resources;
} else {
$data = $resources->where('type', $category);
}
return $data;
}
private function getCategoriesSearchResult(Collection $resources)
{
return $resources->pluck('type')->unique()->values()->all();
}
private function createPaginate($resources, $request, $perPage = 10) : array
{
$currentPage = LengthAwarePaginator::resolveCurrentPage();
// Отрезаем нужные элементы для текущей страницы
$currentItems = $resources->slice(($currentPage - 1) * $perPage, $perPage)->all();
// Создаем экземпляр LengthAwarePaginator
$paginator = new LengthAwarePaginator($currentItems, count($resources), $perPage, $currentPage, [
'path' => $request->url(),
'query' => $request->query,
]);
$nextPage = $paginator->hasMorePages() ? $paginator->currentPage() + 1 : null;
$prevPage = $paginator->onFirstPage() ? null : $paginator->currentPage() - 1;
return [
'paginator' => $paginator,
'next_page' => $nextPage,
'prev_page' => $prevPage
];
}
}
@@ -36,8 +36,6 @@ class HandleInertiaRequests extends Middleware
...parent::share($request),
'auth' => [
'user' => $request->user() ? $request->user()->only('id', 'name', 'email', 'created_at') : null,
'role' => $request->user() ? $request->user()->roles->pluck('name') : null,
'permissions' => $request->user() ? $request->user()->getPermissionsViaRoles()->pluck('name') : null,
],
'ziggy' => fn () => [
...(new Ziggy)->toArray(),
@@ -18,6 +18,7 @@ class ClientPostListResource extends JsonResource
'id' => $this->id,
'title' => $this->title,
'slug' => $this->slug,
'preview_text' => $this->preview_text,
'content' => $this->content,
'category' => $this->category,
'authors' => $this->authors,
@@ -16,7 +16,7 @@ class ClientScheduleSearchResource extends JsonResource
{
return [
'id' => $this->id,
'title' => $this->title,
'file' => $this->file,
];
}
}
@@ -18,6 +18,7 @@ class PostThumbnailResource extends JsonResource
'id' => $this->id,
'title' => $this->title,
'slug' => $this->slug,
'preview_text' => $this->preview_text,
'category' => $this->category,
'authors' => $this->authors,
'preview' => $this->preview,
+105
View File
@@ -0,0 +1,105 @@
<?php
namespace App\Livewire;
use App\Models\AcceptedInvitation;
use App\Models\Invitation;
use App\Models\User;
use Filament\Actions\Action;
use Filament\Facades\Filament;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Form;
use Filament\Pages\Concerns\InteractsWithFormActions;
use Filament\Pages\Dashboard;
use Filament\Pages\SimplePage;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Validation\Rules\Password;
use Livewire\Component;
use function Laravel\Prompts\password;
class AcceptInvitation extends SimplePage
{
use InteractsWithForms;
use InteractsWithFormActions;
protected static string $view = 'livewire.accept-invitation';
public int $invitation;
private Invitation $invitationModel;
public ?array $data = [];
public function mount(): void
{
$this->invitationModel = Invitation::findOrFail($this->invitation);
$this->form->fill([
'email' => $this->invitationModel->email
]);
}
public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name')
->label('Имя')
->required()
->autofocus(),
TextInput::make('email')
->disabled(),
TextInput::make('password')
->label('Пароль')
->password()
->required()
->rule(Password::default())
->dehydrateStateUsing(fn($state) => Hash::make($state))
->same('passwordConfirmation'),
TextInput::make('passwordConfirmation')
->label('Подтверждение пароля')
->password()
->required()
->dehydrated(false)
])->statePath('data');
}
public function create(): void
{
DB::transaction(function () {
$this->invitationModel = Invitation::find($this->invitation);
$user = User::create([
'name' => $this->form->getState()['name'],
'password' => Hash::make($this->form->getState()['password']),
'email' => $this->invitationModel->email,
]);
AcceptedInvitation::create([
'sender_id' => $this->invitationModel->user_id,
'receiver_id' => $user->id,
'post_limit' => 0
]);
auth()->login($user);
$this->invitationModel->delete();
});
$this->redirect(url(Filament::getPanel('dashboard')->getPath()));
}
public function getRegisterFormAction(): Action
{
return Action::make('register')
->submit('Подтвердить');
}
protected function getFormActions(): array
{
return [
$this->getRegisterFormAction()
];
}
}
+63
View File
@@ -0,0 +1,63 @@
<?php
namespace App\Mail;
use App\Models\Invitation;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\URL;
class InvitationMail extends Mailable
{
use Queueable, SerializesModels;
private Invitation $invitation;
/**
* Create a new message instance.
*/
public function __construct(Invitation $invitation)
{
$this->invitation = $invitation;
}
/**
* Get the message envelope.
*/
public function envelope(): Envelope
{
return new Envelope(
subject: 'Invitation Mail',
);
}
/**
* Get the message content definition.
*/
public function content(): Content
{
return new Content(
markdown: 'emails.invitation',
with: [
'acceptUrl' => URL::signedRoute(
'invitation.accept',
['invitation' => $this->invitation]
)
],
);
}
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
*/
public function attachments(): array
{
return [];
}
}
+23
View File
@@ -0,0 +1,23 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class AcceptedInvitation extends Model
{
use HasFactory;
protected $fillable = ['sender_id', 'receiver_id', 'post_limit'];
public function sender()
{
return $this->belongsTo(User::class, 'sender_id');
}
public function receiver()
{
return $this->belongsTo(User::class, 'receiver_id');
}
}
+5
View File
@@ -22,5 +22,10 @@ class AdditionalEducation extends Model
return $this->belongsTo(AdditionalEducationCategory::class, 'category_id', 'id');
}
public function seo()
{
return $this->morphOne(Seo::class, 'seoable');
}
}
@@ -20,4 +20,6 @@ class AdditionalEducationCategory extends Model
{
return $this->belongsTo(DirectionAdditionalEducation::class, 'dir_addit_educat_id', 'id');
}
}
+5
View File
@@ -15,6 +15,11 @@ class Department extends Model
'content' => 'array',
];
public function seo()
{
return $this->morphOne(Seo::class, 'seoable');
}
public function faculty()
{
return $this->belongsTo(Faculty::class);
+5
View File
@@ -15,6 +15,11 @@ class Division extends Model
'description' => 'array',
];
public function seo()
{
return $this->morphOne(Seo::class, 'seoable');
}
public function workers()
{
return $this->belongsToMany(User::class, 'division_user')->withPivot(['administrativePosition', 'sort']);
+5
View File
@@ -35,4 +35,9 @@ class EducationalProgram extends Model
{
return $this->hasMany(AdmissionPlan::class, 'educational_programs_id', 'id');
}
public function seo()
{
return $this->morphOne(Seo::class, 'seoable');
}
}
+5
View File
@@ -17,6 +17,11 @@ class Event extends Model
'content' => 'array',
];
public function seo()
{
return $this->morphOne(Seo::class, 'seoable');
}
public function category() : BelongsTo
{
return $this->belongsTo(EventCategory::class);
+5
View File
@@ -15,6 +15,11 @@ class Faculty extends Model
'content' => 'array',
];
public function seo()
{
return $this->morphOne(Seo::class, 'seoable');
}
public function departments()
{
return $this->hasMany(Department::class);
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Invitation extends Model
{
use HasFactory;
protected $guarded = false;
}
+5
View File
@@ -11,6 +11,11 @@ class LibraryNews extends Model
protected $guarded = false;
public function seo()
{
return $this->morphOne(Seo::class, 'seoable');
}
protected $casts = [
'content' => 'array',
];
+5
View File
@@ -18,6 +18,11 @@ class Page extends Model
return $this->belongsTo(SubSection::class, 'sub_section_id');
}
public function seo()
{
return $this->morphOne(Seo::class, 'seoable');
}
protected $casts = [
'content' => 'array',
];
+5
View File
@@ -22,6 +22,11 @@ class Post extends Model
return $this->belongsTo(Category::class);
}
public function seo()
{
return $this->morphOne(Seo::class, 'seoable');
}
protected $casts = [
'content' => 'array',
'authors' => 'array',
+1 -1
View File
@@ -12,7 +12,7 @@ class Schedule extends Model
protected $guarded = false;
protected $casts = [
'days' => 'array',
'file' => 'array',
];
public function subSchedules()
+18
View File
@@ -0,0 +1,18 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Seo extends Model
{
use HasFactory;
protected $fillable = ['title', 'description'];
public function seoable()
{
return $this->morphTo();
}
}
+37 -2
View File
@@ -3,6 +3,10 @@
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use App\Providers\Filament\AdminPanelProvider;
use BezhanSalleh\FilamentShield\FilamentShield;
use BezhanSalleh\FilamentShield\Support\Utils;
use BezhanSalleh\FilamentShield\Traits\HasPanelShield;
use Filament\Models\Contracts\FilamentUser;
use Filament\Tables\Columns\Layout\Panel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
@@ -13,7 +17,7 @@ use Spatie\Permission\Traits\HasRoles;
class User extends Authenticatable implements FilamentUser
{
use HasApiTokens, HasFactory, Notifiable, HasRoles;
use HasApiTokens, HasFactory, Notifiable, HasRoles, HasPanelShield;
/**
* The attributes that are mass assignable.
@@ -72,8 +76,39 @@ class User extends Authenticatable implements FilamentUser
return $this->belongsToMany(Faculty::class, 'workers_faculties')->withPivot(['position']);
}
// Отношение к отправленным приглашениям
public function sentInvitations()
{
return $this->hasMany(AcceptedInvitation::class, 'sender_id');
}
// Отношение к полученным приглашениям
public function receivedInvitation()
{
return $this->hasOne(AcceptedInvitation::class, 'receiver_id');
}
protected static function booted(): void
{
if (config('filament-shield.dashboard_user.enabled', false)) {
FilamentShield::createRole(name: config('filament-shield.dashboard_user.name', 'dashboard_user'));
static::created(function (User $user) {
$user->assignRole(config('filament-shield.dashboard_user.name', 'dashboard_user'));
});
static::deleting(function (User $user) {
$user->assignRole(config('filament-shield.dashboard_user.name', 'dashboard_user'));
});
}
}
public function canAccessPanel(Panel|\Filament\Panel $panel): bool
{
return true;
switch ($panel->getId()) {
case "admin":
return $this->hasRole(Utils::getSuperAdminName());
case "dashboard":
return $this->hasRole(config('filament-shield.dashboard_user.name', 'dashboard_user')) || $this->hasRole(Utils::getSuperAdminName());
default:
return false;
}
}
}
+2
View File
@@ -8,4 +8,6 @@ use Illuminate\Database\Eloquent\Model;
class VacantPosition extends Model
{
use HasFactory;
}
+5
View File
@@ -14,4 +14,9 @@ class VirtualExhibition extends Model
protected $casts = [
'content' => 'array'
];
public function seo()
{
return $this->morphOne(Seo::class, 'seoable');
}
}
+1 -1
View File
@@ -14,7 +14,7 @@ class CustomFormResponseObserver
*/
public function created(CustomFormResponse $customFormResponse): void
{
dispatch(new SendFormResponseMail($customFormResponse));
!empty($customFormResponse->form->mail_settings) ? dispatch(new SendFormResponseMail($customFormResponse)) : null;
}
/**
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\AcademicJournal;
use Illuminate\Auth\Access\HandlesAuthorization;
class AcademicJournalPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_academic::journal');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, AcademicJournal $academicJournal): bool
{
return $user->can('view_academic::journal');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_academic::journal');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, AcademicJournal $academicJournal): bool
{
return $user->can('update_academic::journal');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, AcademicJournal $academicJournal): bool
{
return $user->can('delete_academic::journal');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_academic::journal');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, AcademicJournal $academicJournal): bool
{
return $user->can('force_delete_academic::journal');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_academic::journal');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, AcademicJournal $academicJournal): bool
{
return $user->can('restore_academic::journal');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_academic::journal');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, AcademicJournal $academicJournal): bool
{
return $user->can('replicate_academic::journal');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_academic::journal');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\AcceptedInvitation;
use Illuminate\Auth\Access\HandlesAuthorization;
class AcceptedInvitationPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_accepted::invitation');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, AcceptedInvitation $acceptedInvitation): bool
{
return $user->can('view_accepted::invitation');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_accepted::invitation');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, AcceptedInvitation $acceptedInvitation): bool
{
return $user->can('update_accepted::invitation');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, AcceptedInvitation $acceptedInvitation): bool
{
return $user->can('delete_accepted::invitation');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_accepted::invitation');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, AcceptedInvitation $acceptedInvitation): bool
{
return $user->can('{{ ForceDelete }}');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('{{ ForceDeleteAny }}');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, AcceptedInvitation $acceptedInvitation): bool
{
return $user->can('{{ Restore }}');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('{{ RestoreAny }}');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, AcceptedInvitation $acceptedInvitation): bool
{
return $user->can('{{ Replicate }}');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('{{ Reorder }}');
}
}
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\AdditionalEducationCategory;
use Illuminate\Auth\Access\HandlesAuthorization;
class AdditionalEducationCategoryPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_additional::education::category');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, AdditionalEducationCategory $additionalEducationCategory): bool
{
return $user->can('view_additional::education::category');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_additional::education::category');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, AdditionalEducationCategory $additionalEducationCategory): bool
{
return $user->can('update_additional::education::category');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, AdditionalEducationCategory $additionalEducationCategory): bool
{
return $user->can('delete_additional::education::category');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_additional::education::category');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, AdditionalEducationCategory $additionalEducationCategory): bool
{
return $user->can('force_delete_additional::education::category');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_additional::education::category');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, AdditionalEducationCategory $additionalEducationCategory): bool
{
return $user->can('restore_additional::education::category');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_additional::education::category');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, AdditionalEducationCategory $additionalEducationCategory): bool
{
return $user->can('replicate_additional::education::category');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_additional::education::category');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\AdditionalEducation;
use Illuminate\Auth\Access\HandlesAuthorization;
class AdditionalEducationPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_additional::education');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, AdditionalEducation $additionalEducation): bool
{
return $user->can('view_additional::education');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_additional::education');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, AdditionalEducation $additionalEducation): bool
{
return $user->can('update_additional::education');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, AdditionalEducation $additionalEducation): bool
{
return $user->can('delete_additional::education');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_additional::education');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, AdditionalEducation $additionalEducation): bool
{
return $user->can('force_delete_additional::education');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_additional::education');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, AdditionalEducation $additionalEducation): bool
{
return $user->can('restore_additional::education');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_additional::education');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, AdditionalEducation $additionalEducation): bool
{
return $user->can('replicate_additional::education');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_additional::education');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\AdmissionCampaign;
use Illuminate\Auth\Access\HandlesAuthorization;
class AdmissionCampaignPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_admission::campaign');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, AdmissionCampaign $admissionCampaign): bool
{
return $user->can('view_admission::campaign');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_admission::campaign');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, AdmissionCampaign $admissionCampaign): bool
{
return $user->can('update_admission::campaign');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, AdmissionCampaign $admissionCampaign): bool
{
return $user->can('delete_admission::campaign');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_admission::campaign');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, AdmissionCampaign $admissionCampaign): bool
{
return $user->can('force_delete_admission::campaign');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_admission::campaign');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, AdmissionCampaign $admissionCampaign): bool
{
return $user->can('restore_admission::campaign');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_admission::campaign');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, AdmissionCampaign $admissionCampaign): bool
{
return $user->can('replicate_admission::campaign');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_admission::campaign');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\AdmissionPlan;
use Illuminate\Auth\Access\HandlesAuthorization;
class AdmissionPlanPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_admission::plan');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, AdmissionPlan $admissionPlan): bool
{
return $user->can('view_admission::plan');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_admission::plan');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, AdmissionPlan $admissionPlan): bool
{
return $user->can('update_admission::plan');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, AdmissionPlan $admissionPlan): bool
{
return $user->can('delete_admission::plan');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_admission::plan');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, AdmissionPlan $admissionPlan): bool
{
return $user->can('force_delete_admission::plan');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_admission::plan');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, AdmissionPlan $admissionPlan): bool
{
return $user->can('restore_admission::plan');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_admission::plan');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, AdmissionPlan $admissionPlan): bool
{
return $user->can('replicate_admission::plan');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_admission::plan');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\Category;
use Illuminate\Auth\Access\HandlesAuthorization;
class CategoryPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_category');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Category $category): bool
{
return $user->can('view_category');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_category');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Category $category): bool
{
return $user->can('update_category');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Category $category): bool
{
return $user->can('delete_category');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_category');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Category $category): bool
{
return $user->can('force_delete_category');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_category');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, Category $category): bool
{
return $user->can('restore_category');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_category');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Category $category): bool
{
return $user->can('replicate_category');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_category');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\CustomForm;
use Illuminate\Auth\Access\HandlesAuthorization;
class CustomFormPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_custom::form');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, CustomForm $customForm): bool
{
return $user->can('view_custom::form');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_custom::form');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, CustomForm $customForm): bool
{
return $user->can('update_custom::form');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, CustomForm $customForm): bool
{
return $user->can('delete_custom::form');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_custom::form');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, CustomForm $customForm): bool
{
return $user->can('force_delete_custom::form');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_custom::form');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, CustomForm $customForm): bool
{
return $user->can('restore_custom::form');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_custom::form');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, CustomForm $customForm): bool
{
return $user->can('replicate_custom::form');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_custom::form');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\CustomFormResponse;
use Illuminate\Auth\Access\HandlesAuthorization;
class CustomFormResponsePolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_custom::form::response');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, CustomFormResponse $customFormResponse): bool
{
return $user->can('view_custom::form::response');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_custom::form::response');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, CustomFormResponse $customFormResponse): bool
{
return $user->can('update_custom::form::response');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, CustomFormResponse $customFormResponse): bool
{
return $user->can('delete_custom::form::response');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_custom::form::response');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, CustomFormResponse $customFormResponse): bool
{
return $user->can('force_delete_custom::form::response');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_custom::form::response');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, CustomFormResponse $customFormResponse): bool
{
return $user->can('restore_custom::form::response');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_custom::form::response');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, CustomFormResponse $customFormResponse): bool
{
return $user->can('replicate_custom::form::response');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_custom::form::response');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\Department;
use Illuminate\Auth\Access\HandlesAuthorization;
class DepartmentPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_department');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Department $department): bool
{
return $user->can('view_department');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_department');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Department $department): bool
{
return $user->can('update_department');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Department $department): bool
{
return $user->can('delete_department');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_department');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Department $department): bool
{
return $user->can('force_delete_department');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_department');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, Department $department): bool
{
return $user->can('restore_department');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_department');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Department $department): bool
{
return $user->can('replicate_department');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_department');
}
}
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\DirectionAdditionalEducation;
use Illuminate\Auth\Access\HandlesAuthorization;
class DirectionAdditionalEducationPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_direction::additional::education');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, DirectionAdditionalEducation $directionAdditionalEducation): bool
{
return $user->can('view_direction::additional::education');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_direction::additional::education');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, DirectionAdditionalEducation $directionAdditionalEducation): bool
{
return $user->can('update_direction::additional::education');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, DirectionAdditionalEducation $directionAdditionalEducation): bool
{
return $user->can('delete_direction::additional::education');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_direction::additional::education');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, DirectionAdditionalEducation $directionAdditionalEducation): bool
{
return $user->can('force_delete_direction::additional::education');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_direction::additional::education');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, DirectionAdditionalEducation $directionAdditionalEducation): bool
{
return $user->can('restore_direction::additional::education');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_direction::additional::education');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, DirectionAdditionalEducation $directionAdditionalEducation): bool
{
return $user->can('replicate_direction::additional::education');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_direction::additional::education');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\DirectionStudy;
use Illuminate\Auth\Access\HandlesAuthorization;
class DirectionStudyPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_direction::study');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, DirectionStudy $directionStudy): bool
{
return $user->can('view_direction::study');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_direction::study');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, DirectionStudy $directionStudy): bool
{
return $user->can('update_direction::study');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, DirectionStudy $directionStudy): bool
{
return $user->can('delete_direction::study');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_direction::study');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, DirectionStudy $directionStudy): bool
{
return $user->can('force_delete_direction::study');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_direction::study');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, DirectionStudy $directionStudy): bool
{
return $user->can('restore_direction::study');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_direction::study');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, DirectionStudy $directionStudy): bool
{
return $user->can('replicate_direction::study');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_direction::study');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\Division;
use Illuminate\Auth\Access\HandlesAuthorization;
class DivisionPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_division');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Division $division): bool
{
return $user->can('view_division');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_division');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Division $division): bool
{
return $user->can('update_division');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Division $division): bool
{
return $user->can('delete_division');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_division');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Division $division): bool
{
return $user->can('force_delete_division');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_division');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, Division $division): bool
{
return $user->can('restore_division');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_division');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Division $division): bool
{
return $user->can('replicate_division');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_division');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\EducationalGroup;
use Illuminate\Auth\Access\HandlesAuthorization;
class EducationalGroupPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_educational::group');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, EducationalGroup $educationalGroup): bool
{
return $user->can('view_educational::group');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_educational::group');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, EducationalGroup $educationalGroup): bool
{
return $user->can('update_educational::group');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, EducationalGroup $educationalGroup): bool
{
return $user->can('delete_educational::group');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_educational::group');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, EducationalGroup $educationalGroup): bool
{
return $user->can('force_delete_educational::group');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_educational::group');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, EducationalGroup $educationalGroup): bool
{
return $user->can('restore_educational::group');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_educational::group');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, EducationalGroup $educationalGroup): bool
{
return $user->can('replicate_educational::group');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_educational::group');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\EducationalProgram;
use Illuminate\Auth\Access\HandlesAuthorization;
class EducationalProgramPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_educational::program');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, EducationalProgram $educationalProgram): bool
{
return $user->can('view_educational::program');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_educational::program');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, EducationalProgram $educationalProgram): bool
{
return $user->can('update_educational::program');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, EducationalProgram $educationalProgram): bool
{
return $user->can('delete_educational::program');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_educational::program');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, EducationalProgram $educationalProgram): bool
{
return $user->can('force_delete_educational::program');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_educational::program');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, EducationalProgram $educationalProgram): bool
{
return $user->can('restore_educational::program');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_educational::program');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, EducationalProgram $educationalProgram): bool
{
return $user->can('replicate_educational::program');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_educational::program');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\EventCategory;
use Illuminate\Auth\Access\HandlesAuthorization;
class EventCategoryPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_event::category');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, EventCategory $eventCategory): bool
{
return $user->can('view_event::category');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_event::category');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, EventCategory $eventCategory): bool
{
return $user->can('update_event::category');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, EventCategory $eventCategory): bool
{
return $user->can('delete_event::category');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_event::category');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, EventCategory $eventCategory): bool
{
return $user->can('force_delete_event::category');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_event::category');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, EventCategory $eventCategory): bool
{
return $user->can('restore_event::category');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_event::category');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, EventCategory $eventCategory): bool
{
return $user->can('replicate_event::category');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_event::category');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\Event;
use Illuminate\Auth\Access\HandlesAuthorization;
class EventPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_event');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Event $event): bool
{
return $user->can('view_event');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_event');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Event $event): bool
{
return $user->can('update_event');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Event $event): bool
{
return $user->can('delete_event');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_event');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Event $event): bool
{
return $user->can('force_delete_event');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_event');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, Event $event): bool
{
return $user->can('restore_event');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_event');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Event $event): bool
{
return $user->can('replicate_event');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_event');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\ExternalVacancy;
use Illuminate\Auth\Access\HandlesAuthorization;
class ExternalVacancyPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_external::vacancy');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, ExternalVacancy $externalVacancy): bool
{
return $user->can('view_external::vacancy');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_external::vacancy');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, ExternalVacancy $externalVacancy): bool
{
return $user->can('update_external::vacancy');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, ExternalVacancy $externalVacancy): bool
{
return $user->can('delete_external::vacancy');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_external::vacancy');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, ExternalVacancy $externalVacancy): bool
{
return $user->can('force_delete_external::vacancy');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_external::vacancy');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, ExternalVacancy $externalVacancy): bool
{
return $user->can('restore_external::vacancy');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_external::vacancy');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, ExternalVacancy $externalVacancy): bool
{
return $user->can('replicate_external::vacancy');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_external::vacancy');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\Faculty;
use Illuminate\Auth\Access\HandlesAuthorization;
class FacultyPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_faculty');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Faculty $faculty): bool
{
return $user->can('view_faculty');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_faculty');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Faculty $faculty): bool
{
return $user->can('update_faculty');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Faculty $faculty): bool
{
return $user->can('delete_faculty');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_faculty');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Faculty $faculty): bool
{
return $user->can('force_delete_faculty');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_faculty');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, Faculty $faculty): bool
{
return $user->can('restore_faculty');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_faculty');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Faculty $faculty): bool
{
return $user->can('replicate_faculty');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_faculty');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\JournalIssue;
use Illuminate\Auth\Access\HandlesAuthorization;
class JournalIssuePolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_journal::issue');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, JournalIssue $journalIssue): bool
{
return $user->can('view_journal::issue');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_journal::issue');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, JournalIssue $journalIssue): bool
{
return $user->can('update_journal::issue');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, JournalIssue $journalIssue): bool
{
return $user->can('delete_journal::issue');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_journal::issue');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, JournalIssue $journalIssue): bool
{
return $user->can('force_delete_journal::issue');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_journal::issue');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, JournalIssue $journalIssue): bool
{
return $user->can('restore_journal::issue');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_journal::issue');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, JournalIssue $journalIssue): bool
{
return $user->can('replicate_journal::issue');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_journal::issue');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\LibraryNews;
use Illuminate\Auth\Access\HandlesAuthorization;
class LibraryNewsPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_library::news');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, LibraryNews $libraryNews): bool
{
return $user->can('view_library::news');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_library::news');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, LibraryNews $libraryNews): bool
{
return $user->can('update_library::news');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, LibraryNews $libraryNews): bool
{
return $user->can('delete_library::news');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_library::news');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, LibraryNews $libraryNews): bool
{
return $user->can('force_delete_library::news');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_library::news');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, LibraryNews $libraryNews): bool
{
return $user->can('restore_library::news');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_library::news');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, LibraryNews $libraryNews): bool
{
return $user->can('replicate_library::news');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_library::news');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\MainSection;
use Illuminate\Auth\Access\HandlesAuthorization;
class MainSectionPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_main::section');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, MainSection $mainSection): bool
{
return $user->can('view_main::section');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_main::section');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, MainSection $mainSection): bool
{
return $user->can('update_main::section');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, MainSection $mainSection): bool
{
return $user->can('delete_main::section');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_main::section');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, MainSection $mainSection): bool
{
return $user->can('force_delete_main::section');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_main::section');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, MainSection $mainSection): bool
{
return $user->can('restore_main::section');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_main::section');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, MainSection $mainSection): bool
{
return $user->can('replicate_main::section');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_main::section');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\MainSlider;
use Illuminate\Auth\Access\HandlesAuthorization;
class MainSliderPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_main::slider');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, MainSlider $mainSlider): bool
{
return $user->can('view_main::slider');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_main::slider');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, MainSlider $mainSlider): bool
{
return $user->can('update_main::slider');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, MainSlider $mainSlider): bool
{
return $user->can('delete_main::slider');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_main::slider');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, MainSlider $mainSlider): bool
{
return $user->can('force_delete_main::slider');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_main::slider');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, MainSlider $mainSlider): bool
{
return $user->can('restore_main::slider');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_main::slider');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, MainSlider $mainSlider): bool
{
return $user->can('replicate_main::slider');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_main::slider');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\Page;
use Illuminate\Auth\Access\HandlesAuthorization;
class PagePolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_url::link');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Page $page): bool
{
return $user->can('view_url::link');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_url::link');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Page $page): bool
{
return $user->can('update_url::link');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Page $page): bool
{
return $user->can('delete_url::link');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_url::link');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Page $page): bool
{
return $user->can('force_delete_url::link');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_url::link');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, Page $page): bool
{
return $user->can('restore_url::link');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_url::link');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Page $page): bool
{
return $user->can('replicate_url::link');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_url::link');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\Post;
use Illuminate\Auth\Access\HandlesAuthorization;
class PostPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_post');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Post $post): bool
{
return $user->can('view_post');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_post');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Post $post): bool
{
return $user->can('update_post');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Post $post): bool
{
return $user->can('delete_post');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_post');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Post $post): bool
{
return $user->can('{{ ForceDelete }}');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('{{ ForceDeleteAny }}');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, Post $post): bool
{
return $user->can('{{ Restore }}');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('{{ RestoreAny }}');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Post $post): bool
{
return $user->can('{{ Replicate }}');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('{{ Reorder }}');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use Spatie\Permission\Models\Role;
use Illuminate\Auth\Access\HandlesAuthorization;
class RolePolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_role');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Role $role): bool
{
return $user->can('view_role');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_role');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Role $role): bool
{
return $user->can('update_role');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Role $role): bool
{
return $user->can('delete_role');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_role');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Role $role): bool
{
return $user->can('{{ ForceDelete }}');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('{{ ForceDeleteAny }}');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, Role $role): bool
{
return $user->can('{{ Restore }}');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('{{ RestoreAny }}');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Role $role): bool
{
return $user->can('{{ Replicate }}');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('{{ Reorder }}');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\Schedule;
use Illuminate\Auth\Access\HandlesAuthorization;
class SchedulePolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_schedule');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Schedule $schedule): bool
{
return $user->can('view_schedule');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_schedule');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Schedule $schedule): bool
{
return $user->can('update_schedule');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Schedule $schedule): bool
{
return $user->can('delete_schedule');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_schedule');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Schedule $schedule): bool
{
return $user->can('force_delete_schedule');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_schedule');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, Schedule $schedule): bool
{
return $user->can('restore_schedule');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_schedule');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Schedule $schedule): bool
{
return $user->can('replicate_schedule');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_schedule');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\SubSection;
use Illuminate\Auth\Access\HandlesAuthorization;
class SubSectionPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_sub::section');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, SubSection $subSection): bool
{
return $user->can('view_sub::section');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_sub::section');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, SubSection $subSection): bool
{
return $user->can('update_sub::section');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, SubSection $subSection): bool
{
return $user->can('delete_sub::section');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_sub::section');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, SubSection $subSection): bool
{
return $user->can('force_delete_sub::section');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_sub::section');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, SubSection $subSection): bool
{
return $user->can('restore_sub::section');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_sub::section');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, SubSection $subSection): bool
{
return $user->can('replicate_sub::section');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_sub::section');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\Tag;
use Illuminate\Auth\Access\HandlesAuthorization;
class TagPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_tag');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Tag $tag): bool
{
return $user->can('view_tag');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_tag');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Tag $tag): bool
{
return $user->can('update_tag');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Tag $tag): bool
{
return $user->can('delete_tag');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_tag');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, Tag $tag): bool
{
return $user->can('force_delete_tag');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_tag');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, Tag $tag): bool
{
return $user->can('restore_tag');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_tag');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, Tag $tag): bool
{
return $user->can('replicate_tag');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_tag');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\UserDetail;
use Illuminate\Auth\Access\HandlesAuthorization;
class UserDetailPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_user::detail');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, UserDetail $userDetail): bool
{
return $user->can('view_user::detail');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_user::detail');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, UserDetail $userDetail): bool
{
return $user->can('update_user::detail');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, UserDetail $userDetail): bool
{
return $user->can('delete_user::detail');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_user::detail');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, UserDetail $userDetail): bool
{
return $user->can('force_delete_user::detail');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_user::detail');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, UserDetail $userDetail): bool
{
return $user->can('restore_user::detail');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_user::detail');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, UserDetail $userDetail): bool
{
return $user->can('replicate_user::detail');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_user::detail');
}
}
+144
View File
@@ -0,0 +1,144 @@
<?php
namespace App\Policies;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class UserPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*
* @param \App\Models\User $user
* @return bool
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_user');
}
/**
* Determine whether the user can view the model.
*
* @param \App\Models\User $user
* @return bool
*/
public function view(User $user): bool
{
return $user->can('view_user');
}
/**
* Determine whether the user can create models.
*
* @param \App\Models\User $user
* @return bool
*/
public function create(User $user): bool
{
return $user->can('create_user');
}
/**
* Determine whether the user can update the model.
*
* @param \App\Models\User $user
* @return bool
*/
public function update(User $user): bool
{
return $user->can('update_user');
}
/**
* Determine whether the user can delete the model.
*
* @param \App\Models\User $user
* @return bool
*/
public function delete(User $user): bool
{
return $user->can('delete_user');
}
/**
* Determine whether the user can bulk delete.
*
* @param \App\Models\User $user
* @return bool
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_user');
}
/**
* Determine whether the user can permanently delete.
*
* @param \App\Models\User $user
* @return bool
*/
public function forceDelete(User $user): bool
{
return $user->can('{{ ForceDelete }}');
}
/**
* Determine whether the user can permanently bulk delete.
*
* @param \App\Models\User $user
* @return bool
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('{{ ForceDeleteAny }}');
}
/**
* Determine whether the user can restore.
*
* @param \App\Models\User $user
* @return bool
*/
public function restore(User $user): bool
{
return $user->can('{{ Restore }}');
}
/**
* Determine whether the user can bulk restore.
*
* @param \App\Models\User $user
* @return bool
*/
public function restoreAny(User $user): bool
{
return $user->can('{{ RestoreAny }}');
}
/**
* Determine whether the user can bulk restore.
*
* @param \App\Models\User $user
* @return bool
*/
public function replicate(User $user): bool
{
return $user->can('{{ Replicate }}');
}
/**
* Determine whether the user can reorder.
*
* @param \App\Models\User $user
* @return bool
*/
public function reorder(User $user): bool
{
return $user->can('{{ Reorder }}');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\VacantPosition;
use Illuminate\Auth\Access\HandlesAuthorization;
class VacantPositionPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_vacant::position');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, VacantPosition $vacantPosition): bool
{
return $user->can('view_vacant::position');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_vacant::position');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, VacantPosition $vacantPosition): bool
{
return $user->can('update_vacant::position');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, VacantPosition $vacantPosition): bool
{
return $user->can('delete_vacant::position');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_vacant::position');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, VacantPosition $vacantPosition): bool
{
return $user->can('force_delete_vacant::position');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_vacant::position');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, VacantPosition $vacantPosition): bool
{
return $user->can('restore_vacant::position');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_vacant::position');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, VacantPosition $vacantPosition): bool
{
return $user->can('replicate_vacant::position');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_vacant::position');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
namespace App\Policies;
use App\Models\User;
use App\Models\VirtualExhibition;
use Illuminate\Auth\Access\HandlesAuthorization;
class VirtualExhibitionPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return $user->can('view_any_virtual::exhibition');
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, VirtualExhibition $virtualExhibition): bool
{
return $user->can('view_virtual::exhibition');
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return $user->can('create_virtual::exhibition');
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, VirtualExhibition $virtualExhibition): bool
{
return $user->can('update_virtual::exhibition');
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, VirtualExhibition $virtualExhibition): bool
{
return $user->can('delete_virtual::exhibition');
}
/**
* Determine whether the user can bulk delete.
*/
public function deleteAny(User $user): bool
{
return $user->can('delete_any_virtual::exhibition');
}
/**
* Determine whether the user can permanently delete.
*/
public function forceDelete(User $user, VirtualExhibition $virtualExhibition): bool
{
return $user->can('force_delete_virtual::exhibition');
}
/**
* Determine whether the user can permanently bulk delete.
*/
public function forceDeleteAny(User $user): bool
{
return $user->can('force_delete_any_virtual::exhibition');
}
/**
* Determine whether the user can restore.
*/
public function restore(User $user, VirtualExhibition $virtualExhibition): bool
{
return $user->can('restore_virtual::exhibition');
}
/**
* Determine whether the user can bulk restore.
*/
public function restoreAny(User $user): bool
{
return $user->can('restore_any_virtual::exhibition');
}
/**
* Determine whether the user can replicate.
*/
public function replicate(User $user, VirtualExhibition $virtualExhibition): bool
{
return $user->can('replicate_virtual::exhibition');
}
/**
* Determine whether the user can reorder.
*/
public function reorder(User $user): bool
{
return $user->can('reorder_virtual::exhibition');
}
}
+2
View File
@@ -2,6 +2,8 @@
namespace App\Providers;
use App\Models\Post;
use App\Observers\PostObserver;
use Carbon\Carbon;
use Filament\Facades\Filament;
use Illuminate\Database\Eloquent\Model;
@@ -27,6 +27,7 @@ class AdminPanelProvider extends PanelProvider
->default()
->id('admin')
->path('admin')
->registration()
->login()
->databaseNotifications()
->databaseNotificationsPolling('5s')
@@ -55,8 +56,9 @@ class AdminPanelProvider extends PanelProvider
])
->authMiddleware([
Authenticate::class,
]
)
;
])
->plugins([
\BezhanSalleh\FilamentShield\FilamentShieldPlugin::make()
]);
}
}
@@ -26,9 +26,10 @@ class DashboardPanelProvider extends PanelProvider
->id('dashboard')
->path('dashboard')
->colors([
'primary' => Color::Indigo,
'primary' => Color::Amber,
])
->discoverResources(in: app_path('Filament/Dashboard/Resources'), for: 'App\\Filament\\Dashboard\\Resources')
->login()
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
->discoverPages(in: app_path('Filament/Dashboard/Pages'), for: 'App\\Filament\\Dashboard\\Pages')
->pages([
Pages\Dashboard::class,
@@ -51,6 +52,9 @@ class DashboardPanelProvider extends PanelProvider
])
->authMiddleware([
Authenticate::class,
])
->plugins([
\BezhanSalleh\FilamentShield\FilamentShieldPlugin::make()
]);
}
}

Some files were not shown because too many files have changed in this diff Show More