1 | <?php |
||
2 | |||
3 | namespace App; |
||
4 | |||
5 | use Illuminate\Notifications\Notifiable; |
||
6 | use Illuminate\Contracts\Auth\MustVerifyEmail; |
||
7 | use Carbon\Carbon; |
||
8 | use Illuminate\Foundation\Auth\User as Authenticatable; |
||
9 | use Illuminate\Support\Facades\Auth; |
||
10 | |||
11 | class User extends Authenticatable |
||
12 | { |
||
13 | use Notifiable; |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
14 | |||
15 | /** |
||
16 | * The attributes that are mass assignable. |
||
17 | * |
||
18 | * @var array |
||
19 | */ |
||
20 | protected $fillable = [ |
||
21 | 'name', 'biography', 'profile_picture', 'email', 'password', 'provider', 'provider_id' |
||
22 | ]; |
||
23 | |||
24 | /** |
||
25 | * The attributes that should be hidden for arrays. |
||
26 | * |
||
27 | * @var array |
||
28 | */ |
||
29 | protected $hidden = [ |
||
30 | 'password', 'remember_token', |
||
31 | ]; |
||
32 | |||
33 | /** |
||
34 | * The attributes that should be cast to native types. |
||
35 | * |
||
36 | * @var array |
||
37 | */ |
||
38 | protected $casts = [ |
||
39 | 'email_verified_at' => 'datetime', |
||
40 | ]; |
||
41 | |||
42 | /** |
||
43 | * @var array |
||
44 | */ |
||
45 | protected $dates = [ |
||
46 | 'created_at', |
||
47 | 'updated_at' |
||
48 | ]; |
||
49 | |||
50 | public function thread() { |
||
51 | return $this->hasMany('App\Thread', 'user_id'); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @return int |
||
56 | */ |
||
57 | public function threadAnswered() { |
||
58 | return count( |
||
59 | Thread::where('status', true) |
||
60 | ->where('user_id', Auth::guard('web') |
||
61 | ->user()->id) |
||
62 | ->get() |
||
63 | ); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @param string $str |
||
68 | * @return string |
||
69 | */ |
||
70 | public function trimStr(string $str) |
||
71 | { |
||
72 | if(strlen($str) > 50) { |
||
73 | return substr($str, '0', '50')."..."; |
||
74 | } |
||
75 | return $str; |
||
76 | } |
||
77 | } |
||
78 |