Banner.php
967 Bytes
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
<?php
namespace AC\Admin;
use AC\IntegrationRepository;
use AC\Integrations;
use AC\Promo;
use AC\PromoCollection;
use AC\View;
class Banner
{
private $integrations;
public function __construct()
{
$this->integrations = new IntegrationRepository();
}
private function get_active_promotion(): ?Promo
{
return (new PromoCollection())->find_active();
}
private function get_missing_integrations(): Integrations
{
return $this->integrations->find_all_by_active_plugins();
}
public function render(): string
{
$banner = new View([
'promo' => $this->get_active_promotion(),
'integrations' => $this->get_missing_integrations()->all(),
'discount' => 10,
]);
$banner->set_template('admin/side-banner');
return $banner->render();
}
public function __toString()
{
return $this->render();
}
}