-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBuyable.php
More file actions
51 lines (39 loc) · 1.27 KB
/
Buyable.php
File metadata and controls
51 lines (39 loc) · 1.27 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
<?php
declare(strict_types=1);
/**
* Contains the Buyable interface.
*
* @copyright Copyright (c) 2017 Attila Fulop
* @author Attila Fulop
* @license MIT
* @since 2017-10-28
*
*/
namespace Vanilo\Contracts;
use Carbon\Carbon;
interface Buyable extends HasImages
{
public function getId(): string|int;
public function getName(): string;
public function getPrice(): float;
public function getOriginalPrice(): ?float;
public function hasAHigherOriginalPrice(): bool;
public function addSale(Carbon $date, int|float $units = 1): void;
public function removeSale(int|float $units = 1): void;
/**
* Return the name to use for saving to the db as type name.
*
* It could be either the full class name, or any other string.
*
* 1. If it's not the FQCN, you must add the type to `Relation::morphMap`
*
* 2. It it's the FQCN, then the full class name gets saved. It's
* more simple, but if you'll ever change the classname, it
* means you need to migrate the DB to replace the names
*
* @see https://laravel.com/docs/5.5/eloquent-relationships#polymorphic-relations -> Custom Polymorphic Types
*
* @return string
*/
public function morphTypeName(): string;
}