Conditions | 3 |
Paths | 1 |
Total Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
42 | protected static function bootUserAffiliate() |
||
43 | { |
||
44 | static::creating(function ($model) { |
||
45 | $model->affiliate_id = self::generateAffiliateId(); |
||
46 | }); |
||
47 | |||
48 | static::created(function ($model) { |
||
49 | $affiliateId = Cookie::get(config('referral.ref_cookie')); |
||
50 | if ($affiliateId && $referrer = static::whereAffiliateId($affiliateId)->first()) { |
||
51 | Referral::create(['referrer_id' => $referrer->id, 'referral_id' => $model->id]); |
||
52 | } |
||
53 | }); |
||
54 | } |
||
55 | |||
68 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: