mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
book cases added
This commit is contained in:
43
app/Http/Livewire/Frontend/CommentBookCase.php
Normal file
43
app/Http/Livewire/Frontend/CommentBookCase.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Frontend;
|
||||
|
||||
use App\Models\BookCase;
|
||||
use Livewire\Component;
|
||||
|
||||
class CommentBookCase extends Component
|
||||
{
|
||||
public string $c = 'de';
|
||||
|
||||
public BookCase $bookCase;
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.frontend.comment-book-case');
|
||||
}
|
||||
|
||||
protected function url_to_absolute($url)
|
||||
{
|
||||
// Determine request protocol
|
||||
$request_protocol = $request_protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http');
|
||||
// If dealing with a Protocol Relative URL
|
||||
if (stripos($url, '//') === 0) {
|
||||
return $url;
|
||||
}
|
||||
// If dealing with a Root-Relative URL
|
||||
if (stripos($url, '/') === 0) {
|
||||
return $request_protocol.'://'.$_SERVER['HTTP_HOST'].$url;
|
||||
}
|
||||
// If dealing with an Absolute URL, just return it as-is
|
||||
if (stripos($url, 'http') === 0) {
|
||||
return $url;
|
||||
}
|
||||
// If dealing with a relative URL,
|
||||
// and attempt to handle double dot notation ".."
|
||||
do {
|
||||
$url = preg_replace('/[^\/]+\/\.\.\//', '', $url, 1, $count);
|
||||
} while ($count);
|
||||
// Return the absolute version of a Relative URL
|
||||
return $request_protocol.'://'.$_SERVER['HTTP_HOST'].'/'.$url;
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,15 @@ namespace App\Http\Livewire\Tables;
|
||||
use App\Models\BookCase;
|
||||
use Rappasoft\LaravelLivewireTables\DataTableComponent;
|
||||
use Rappasoft\LaravelLivewireTables\Views\Column;
|
||||
use Rappasoft\LaravelLivewireTables\Views\Columns\BooleanColumn;
|
||||
|
||||
class BookCaseTable extends DataTableComponent
|
||||
{
|
||||
public bool $viewingModal = false;
|
||||
public $currentModal;
|
||||
public array $orangepill = [
|
||||
'amount' => 1,
|
||||
'date' => null,
|
||||
];
|
||||
protected $model = BookCase::class;
|
||||
|
||||
public function configure(): void
|
||||
@@ -22,6 +27,7 @@ class BookCaseTable extends DataTableComponent
|
||||
];
|
||||
})
|
||||
->setTdAttributes(function (Column $column, $row, $columnIndex, $rowIndex) {
|
||||
|
||||
return [
|
||||
'class' => 'px-6 py-4 text-sm font-medium dark:text-white',
|
||||
'default' => false,
|
||||
@@ -48,8 +54,8 @@ class BookCaseTable extends DataTableComponent
|
||||
) => $row->homepage ? '<a target="_blank" class="underline text-amber-500" href="'.$this->url_to_absolute($row->homepage).'">Link</a>' : null
|
||||
)
|
||||
->html(),
|
||||
Column::make('Oranged-Pilled', 'deactivated')
|
||||
->label(fn($row, Column $column) => view('columns.book_cases.oranged-pilled')->withRow($row)),
|
||||
Column::make('Orange-Pilled', 'orange_pilled')
|
||||
->label(fn($row, Column $column) => view('columns.book_cases.oranged-pilled')->withRow($row)),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -77,4 +83,20 @@ class BookCaseTable extends DataTableComponent
|
||||
// Return the absolute version of a Relative URL
|
||||
return $request_protocol.'://'.$_SERVER['HTTP_HOST'].'/'.$url;
|
||||
}
|
||||
|
||||
public function viewHistoryModal($modelId): void
|
||||
{
|
||||
$this->viewingModal = true;
|
||||
$this->currentModal = BookCase::findOrFail($modelId);
|
||||
}
|
||||
|
||||
public function resetModal(): void
|
||||
{
|
||||
$this->reset('viewingModal', 'currentModal');
|
||||
}
|
||||
|
||||
public function customView(): string
|
||||
{
|
||||
return 'modals.book_cases.orange_pill';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user