Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 10 |
CRAP | |
0.00% |
0 / 1 |
| AdminUserInvitation | |
0.00% |
0 / 12 |
|
0.00% |
0 / 10 |
132 | |
0.00% |
0 / 1 |
| company | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| plan | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| company_group | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| company_subgroup | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getInvitationLinkForAdminPortal | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| subscription | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| getStatusAttribute | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| sendPasswordResetNotification | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| user | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| newFactory | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Models\Admin; |
| 4 | |
| 5 | use App\Http\Models\Auth\BaseUser as Authenticatable; |
| 6 | use App\Http\Models\Plans; |
| 7 | use App\Notifications\User\ResetPassword; |
| 8 | use App\Observers\CompanyObserver; |
| 9 | use App\Traits\CustomHasRoles; |
| 10 | use Database\Factories\Http\Models\AdminUserInvitationFactory; |
| 11 | use Illuminate\Contracts\Auth\MustVerifyEmail; |
| 12 | use Illuminate\Database\Eloquent\Attributes\ObservedBy; |
| 13 | use Illuminate\Database\Eloquent\Factories\HasFactory; |
| 14 | use Illuminate\Notifications\Notifiable; |
| 15 | use Laravel\Cashier\Billable; |
| 16 | use Laravel\Passport\HasApiTokens; |
| 17 | use MongoDB\Laravel\Eloquent\SoftDeletes; |
| 18 | use Mpociot\Teamwork\Traits\UserHasTeams; |
| 19 | |
| 20 | /** |
| 21 | * @property string $admin_email |
| 22 | * @property string $email |
| 23 | * @property string $password |
| 24 | * @property string $temp_password |
| 25 | * @property string $temp_password_expiry |
| 26 | * @property string|null $reminder_job_id |
| 27 | * @property string $status |
| 28 | */ |
| 29 | // #[ObservedBy([CompanyObserver::class])] |
| 30 | class AdminUserInvitation extends Authenticatable implements MustVerifyEmail |
| 31 | { |
| 32 | use Billable, CustomHasRoles, HasApiTokens, HasFactory, Notifiable, SoftDeletes, UserHasTeams; |
| 33 | |
| 34 | protected $fillable = [ |
| 35 | 'admin_email', |
| 36 | 'status', |
| 37 | 'email', |
| 38 | 'plan_id', |
| 39 | 'plan', |
| 40 | 'company_id', |
| 41 | 'company_group_id', |
| 42 | 'company_subgroup_id', |
| 43 | 'temp_password_expiry', |
| 44 | 'temp_password', |
| 45 | 'password', |
| 46 | 'role_name', |
| 47 | 'has_corporate_plan', |
| 48 | 'move_assign', |
| 49 | 'user_info_id', |
| 50 | 'reminder_job_id', |
| 51 | ]; |
| 52 | |
| 53 | protected $appends = [ |
| 54 | 'status', |
| 55 | ]; |
| 56 | |
| 57 | public function company() |
| 58 | { |
| 59 | return $this->belongsTo(Company::class); |
| 60 | } |
| 61 | |
| 62 | public function plan() |
| 63 | { |
| 64 | return $this->belongsTo(Plans::class); |
| 65 | } |
| 66 | |
| 67 | public function company_group() |
| 68 | { |
| 69 | return $this->belongsTo(CompanyGroup::class, 'company_group_id'); |
| 70 | } |
| 71 | |
| 72 | public function company_subgroup() |
| 73 | { |
| 74 | return $this->belongsTo(CompanyGroup::class, 'company_subgroup_id'); |
| 75 | } |
| 76 | |
| 77 | public function getInvitationLinkForAdminPortal() |
| 78 | { |
| 79 | return config('romeo.frontend-base-url').'/session/signup?email='.$this->email; |
| 80 | } |
| 81 | |
| 82 | public function subscription($type = 'main') |
| 83 | { |
| 84 | if ($type == 'invitation') { |
| 85 | $plan = Plans::find($this->plan_id); |
| 86 | |
| 87 | return $plan; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | public function getStatusAttribute() |
| 92 | { |
| 93 | return 'Invited'; |
| 94 | } |
| 95 | |
| 96 | public function sendPasswordResetNotification($token) |
| 97 | { |
| 98 | $this->notify(new ResetPassword($token)); |
| 99 | } |
| 100 | |
| 101 | public function user() |
| 102 | { |
| 103 | return $this->belongsTo(User::class, 'email', 'email'); |
| 104 | } |
| 105 | |
| 106 | protected static function newFactory(): AdminUserInvitationFactory |
| 107 | { |
| 108 | return AdminUserInvitationFactory::new(); |
| 109 | } |
| 110 | } |