Karthick K
Karthick K
Explore posts from servers
FFilament
Created by Karthick K on 6/13/2024 in #❓┊help
Spatie Media Library on a custom page
<?php

namespace App\Filament\Admin\Resources\CertificateResource\Pages;

use App\Filament\Admin\Resources\CertificateResource;
use App\Models\Certificate;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\Page;

class UploadCertificate extends Page implements HasForms
{
use InteractsWithForms;

public Certificate $record;

public array $data = [];

protected static string $resource = CertificateResource::class;

protected static string $view = 'filament.admin.resources.certificate-resource.pages.upload-certificate';

public function mount(Certificate $record): void
{
$this->record = $record;

$record->load(['device','media']);

$this->form->fill([
'serial_number' => $record->serial_number,
'device_id' => $record->device->ecu_number,
'certificate' => $record->getMedia(),
]);
}

public function form(Form $form): Form
{
return $form->schema([
Section::make('Certificate Copy')
->schema([
SpatieMediaLibraryFileUpload::make('media')
->label('Upload Scanned Certificate'),
]),
])->statePath('data')
->model($this->record);
}

public function submit(): void
{

}
}
<?php

namespace App\Filament\Admin\Resources\CertificateResource\Pages;

use App\Filament\Admin\Resources\CertificateResource;
use App\Models\Certificate;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\Page;

class UploadCertificate extends Page implements HasForms
{
use InteractsWithForms;

public Certificate $record;

public array $data = [];

protected static string $resource = CertificateResource::class;

protected static string $view = 'filament.admin.resources.certificate-resource.pages.upload-certificate';

public function mount(Certificate $record): void
{
$this->record = $record;

$record->load(['device','media']);

$this->form->fill([
'serial_number' => $record->serial_number,
'device_id' => $record->device->ecu_number,
'certificate' => $record->getMedia(),
]);
}

public function form(Form $form): Form
{
return $form->schema([
Section::make('Certificate Copy')
->schema([
SpatieMediaLibraryFileUpload::make('media')
->label('Upload Scanned Certificate'),
]),
])->statePath('data')
->model($this->record);
}

public function submit(): void
{

}
}
This is my code and I know I am missing something. All the documentation relating to Spatie media library is confusing. Can you someone help me what I have to do to upload and edit the image uploaded later. Submit method is empty coz i don't really know what to put here now.
11 replies
RRailway
Created by Karthick K on 1/29/2024 in #✋|help
internal communication in railway not working.
I am trying to deploy a laravel application in docker. Due to certain requirements I need to deploy it in two containers. one laravel container which runs php-fpm and another one is nginx server. I have enable private network for both the containers and I named the fpm contanier private domain app. Now if I use app:9000 in the proxy pass it is not working getting host not found in upstream "app" in /etc/nginx/conf.d/default.conf:30 error. everthing works for me in local. can someone help on this ?
16 replies