When an event is created, there needs to be the ability to add various Addon
objects to that Event
object. There will need to be various types of Addon
's that we can create, which will be create-able from the admin panel.
The Addon
interface will act as a "contract" so to speak. It will define the basic methods that are needed for an object to be considered an Addon
while leaving the actual implementation/functionality ambiguous, and tentative for each implementation of the Addon
interface.
The Addon
interface will have several methods, and I thought these were the most appropriate:
/**
* Get the price of the Addon.
*
* @return int
*/
public function getPriceAttribute();
/**
* Get the description of the Addon.
*
* @return string
*/
public function getDescriptionAttribute();
/**
* Get any custom modifiers of the Addon.
*
* @return array
*/
public function getModifiersAttribute();
The first Addon
subclass would be TShirt
. It'd look something like this:
public class TShirt extends Model implements Addon
{
public function registration()
{
return $this->belongsTo(Registration::class);
}
public function getPriceAttribute()
{
return $this->price;
}
public function getDescriptionAttribute()
{
return $this->description;
}
public function getModifiersAttribute()
{
return $this->modifiers;
}
public function getSizeAttribute()
{
return $this->size;
}
}
The next Addon
subclass would be Bracelet
. It'd look something like this:
public class Bracelet extends Model implements Addon
{
public function registration()
{
return $this->belongsTo(Registration::class);
}
public function getPriceAttribute()
{
return $this->price;
}
public function getDescriptionAttribute()
{
return $this->description;
}
public function getModifiersAttribute()
{
return $this->modifiers;
}
// Maybe? I'm not sure what the bracelets are...
public function getColorAttribute()
{
return $this->color;
}
}