42 lines
867 B
PHP
42 lines
867 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\View\Components;
|
||
|
|
|
||
|
|
use App\Models\Entry;
|
||
|
|
use App\Models\News;
|
||
|
|
use Closure;
|
||
|
|
use Illuminate\Contracts\View\View;
|
||
|
|
use Illuminate\View\Component;
|
||
|
|
|
||
|
|
class ShareRhpzUrl extends Component
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Create a new component instance.
|
||
|
|
*/
|
||
|
|
public function __construct(
|
||
|
|
public Entry|News $entry,
|
||
|
|
)
|
||
|
|
{
|
||
|
|
//
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the view / contents that represent the component.
|
||
|
|
*/
|
||
|
|
public function render(): View|Closure|string
|
||
|
|
{
|
||
|
|
if( ( $this->entry->type ?? "news" ) === 'news' ){
|
||
|
|
$letter = 'n';
|
||
|
|
} else {
|
||
|
|
$letter = $this->entry->type[0];
|
||
|
|
}
|
||
|
|
|
||
|
|
$id = $this->entry->id;
|
||
|
|
$shareUrl = config('app.share_url');
|
||
|
|
|
||
|
|
$url = rtrim($shareUrl, '/') . '/' . $letter . '/' . $id;
|
||
|
|
|
||
|
|
return view('components.share-rhpz-url', compact('url') );
|
||
|
|
}
|
||
|
|
}
|