-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCardLayout.php
More file actions
76 lines (56 loc) · 1.37 KB
/
CardLayout.php
File metadata and controls
76 lines (56 loc) · 1.37 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
namespace ACTTraining\QueryBuilder\Support;
class CardLayout
{
protected ?string $imageKey = null;
protected ?string $placeholderImage = null;
protected int $gridColumns = 3;
protected string $cardView = 'query-builder::card';
public static function make(): self
{
return new self;
}
public function image(string $key): static
{
$this->imageKey = $key;
return $this;
}
public function placeholder(string $url): static
{
$this->placeholderImage = $url;
return $this;
}
public function columns(int $columns): static
{
$this->gridColumns = $columns;
return $this;
}
public function view(string $view): static
{
$this->cardView = $view;
return $this;
}
public function getImageKey(): ?string
{
return $this->imageKey;
}
public function getPlaceholderImage(): ?string
{
return $this->placeholderImage;
}
public function getGridColumns(): int
{
return $this->gridColumns;
}
public function getCardView(): string
{
return $this->cardView;
}
public function getImageUrl(mixed $row): ?string
{
if (! $this->imageKey) {
return null;
}
return data_get($row, $this->imageKey) ?? $this->placeholderImage;
}
}