StudentImportFailure   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
c 0
b 0
f 0
dl 0
loc 42
rs 10
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 7 1
A __construct() 0 18 5
1
<?php
2
3
namespace App\Mail;
4
5
use App\Models\User;
6
use App\Models\Institution_class;
7
use Illuminate\Bus\Queueable;
8
use Illuminate\Mail\Mailable;
9
use Illuminate\Queue\SerializesModels;
10
11
class StudentImportFailure extends Mailable
12
{
13
    use Queueable, SerializesModels;
0 ignored issues
show
introduced by
The trait Illuminate\Queue\SerializesModels requires some properties which are not provided by App\Mail\StudentImportFailure: $id, $relations, $class, $keyBy
Loading history...
14
15
    /**
16
     * Create a new message instance.
17
     *
18
     * @return void
19
     */
20
    public function __construct($file)
21
    {
22
23
        $institution = Institution_class::find($file['institution_class_id']);
24
25
26
        $this->user = User::find($file['security_user_id']);
0 ignored issues
show
Bug Best Practice introduced by
The property user does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
27
        $this->subject = 'SIS Bulk Upload: ' .$file['subject']. $institution->institution->code.': '. $institution->name.' '. date('Y:m:d H:i:s');
0 ignored issues
show
Bug introduced by
The property name does not seem to exist on App\Models\Institution_class. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
Bug introduced by
The property code does not seem to exist on App\Models\Institution. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
28
        $this->from_address = env('MAIL_FROM_ADDRESS');
0 ignored issues
show
Bug Best Practice introduced by
The property from_address does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
29
        $this->from_name = 'SIS Bulk Uploader';
0 ignored issues
show
Bug Best Practice introduced by
The property from_name does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
30
        $this->with = [
0 ignored issues
show
Bug Best Practice introduced by
The property with does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
31
            'name' => $this->user->first_name,
32
            'link' =>  \App::environment('local') || \App::environment('stage')  ?  env('APP_URL').'/download/' .$file['filename'] : env('APP_URL').'/bulk-upload/download/' .$file['filename']
33
        ];
34
        $this->viewData = [
35
            'name'=>$this->user->first_name, "body" => "We found some errors on your data file ". $file['filename']. ' Pleas fix the errors and re-upload  only with incorrect data,
36
            We uploaded the correct data to the system',
37
            'link' =>  \App::environment('local') || \App::environment('stage')   ?  env('APP_URL').'/download/' .$file['filename'] : env('APP_URL').'/bulk-upload/download/' .$file['filename']
38
        ];
39
    }
40
41
    /**
42
     * Build the message.
43
     *
44
     * @return $this
45
     */
46
    public function build()
47
    {
48
        return $this->view('emails.mail')
49
            ->from($this->from_address,$this->from_name)
50
            ->to($this->user->email)
0 ignored issues
show
Bug introduced by
The property email does not seem to exist on App\Models\User. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
51
            ->subject($this->subject)
52
            ->with($this->with);
53
    }
54
55
}
56