-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathGithub.php
executable file
·51 lines (44 loc) · 1.12 KB
/
Github.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace App\View\Components\Posts;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Validator;
use Illuminate\View\Component;
class Github extends Component
{
/**
* Create a new component instance.
*/
public function __construct(public string $link, public string $title, public $description = null)
{
//
}
/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.posts.github');
}
/**
* Determine if the component should be rendered.
*
* @return bool
*/
public function shouldRender()
{
$validator = Validator::make([
'link' => $this->link,
'title' => $this->title,
'description' => $this->description,
], [
'link' => 'required|url',
'title' => 'required|string',
'description' => 'required|string',
]);
if ($validator->fails()) {
return false;
}
return true;
}
}