Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
SingleOptin
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 booted
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 brand
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Models;
4
5use Illuminate\Database\Eloquent\Factories\HasFactory;
6use Illuminate\Database\Eloquent\Model;
7use Illuminate\Support\Str;
8
9/**
10 * @property integer $hashcode                           Hashcode.
11 * @property integer $brand_id                           Foreign key Brand.
12 * @property string  $email                              Email.
13 * @property-read \Illuminate\Support\Carbon $created_at Created date.
14 * @property-read \Illuminate\Support\Carbon $updated_at Updated date.
15
16 * @property-read \App\Models\Brand $brand Brand BelongsTo relation.
17 */
18class SingleOptin extends Model
19{
20    use HasFactory;
21
22    /**
23     * The primary key for the model.
24     *
25     * @var string
26     */
27    protected $primaryKey = 'hashcode';
28
29    /**
30     * The "type" of the primary key ID.
31     *
32     * @var string
33     */
34    protected $keyType = 'uuid';
35
36    /**
37     * Indicates if the IDs are auto-incrementing.
38     *
39     * @var boolean
40     */
41    public $incrementing = false;
42
43    /**
44     * The attributes that are mass assignable.
45     *
46     * @var string[]
47     */
48    protected $fillable = [
49        'email',
50    ];
51
52    /**
53     * Perform any actions required after the model boots.
54     *
55     * @return void
56     */
57    protected static function booted(): void
58    {
59        static::creating(function (self $model) {
60            $model->hashcode = Str::uuid();
61        });
62    }
63
64    // * RELATIONS
65
66    /**
67     * Brand BelongsTo relation.
68     *
69     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
70     */
71    public function brand(): \Illuminate\Database\Eloquent\Relations\BelongsTo
72    {
73        return $this->belongsTo(Brand::class);
74    }
75}