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