Skip to content

Commit

Permalink
Merge pull request #20 from lara-zeus/upload-field
Browse files Browse the repository at this point in the history
small fixes
  • Loading branch information
atmonshi authored Sep 11, 2022
2 parents dbbab44 + e31eea7 commit 8144f27
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
3 changes: 3 additions & 0 deletions resources/views/fields/file-upload.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<a target="_blank" href="{{ Storage::disk(config('zeus-bolt.uploads.disk'))->url($resp->response) }}">
view file
</a>
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
@foreach($getRecord()->fieldsResponses as $resp)
<div class="py-2">
<p>{{ $resp->field->name }}</p>
<p class="font-semibold mb-2">{{ ( new $resp->field->type )->getResponse($resp->field, $resp) }}</p>
<p class="font-semibold mb-2">{!! ( new $resp->field->type )->getResponse($resp->field, $resp) !!}</p>
<x-filament::hr/>
</div>
@endforeach
Expand Down
9 changes: 9 additions & 0 deletions src/Fields/Classes/FileUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace LaraZeus\Bolt\Fields\Classes;

use Filament\Forms\Components\Toggle;
use Illuminate\Support\Facades\Storage;
use LaraZeus\Bolt\Fields\FieldsContract;

class FileUpload extends FieldsContract
Expand All @@ -23,4 +24,12 @@ public static function getOptions()
Toggle::make('options.is_multiple')->label(__('Allow Multiple')),
];
}

public function getResponse($field, $resp): string
{
return view('zeus-bolt::fields.file-upload')
->with('resp',$resp)
->with('field',$field)
->render();
}
}
8 changes: 7 additions & 1 deletion src/Http/Livewire/FillForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ protected function getFormSchema() : array
$setField->inline();
}
}

if($field->type == '\LaraZeus\Bolt\Fields\Classes\FileUpload'){
$setField
->disk(config('zeus-bolt.uploads.disk'))
->directory(config('zeus-bolt.uploads.directory'));
}
// todo so ugly change!

$fields[] = Forms\Components\Card::make()->schema([ $setField ]);
Expand Down Expand Up @@ -120,6 +126,6 @@ public function store()

public function render()
{
return view('zeus-bolt::forms.fill-forms')->layout('zeus::components.app');
return view('zeus-bolt::forms.fill-forms')->layout(config('zeus-bolt.layout'));
}
}
2 changes: 1 addition & 1 deletion src/Http/Livewire/ListEntries.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ public function fields()

public function render()
{
return view('zeus-bolt::forms.entries')->layout('zeus::components.app');
return view('zeus-bolt::forms.entries')->layout(config('zeus-bolt.layout'));
}
}

0 comments on commit 8144f27

Please sign in to comment.