- Timestamp:
- 09/30/21 00:32:27 (3 years ago)
- Branches:
- develop, master
- Children:
- 24a616f
- Parents:
- 582789f
- Location:
- app
- Files:
-
- 16 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Models/User.php
r582789f r194a359 24 24 "password", 25 25 "email", 26 "country_code",27 26 "mobile_number", 28 27 "role_id" … … 50 49 public function role() { 51 50 return $this->belongsTo(Role::class); 52 }53 54 public function post() {55 return $this->hasMany(Post::class);56 }57 58 public function comments()59 {60 return $this->hasManyThrough(Comment::class, Post::class);61 51 } 62 52 … … 108 98 109 99 public function isAdmin() { 110 return $this->hasRole(" admin");100 return $this->hasRole("Admin"); 111 101 } 112 102 113 103 public function isAdminOrEditor() { 114 return $this->hasRole(" admin") || $this->hasRole("editor");104 return $this->hasRole("Admin") || $this->hasRole("Referent"); 115 105 } 116 106 … … 123 113 124 114 return $this->name . " " . $this->surname; 125 }126 127 public function getPostsCount($id) {128 return Post::where("user_id", $id)->count();129 115 } 130 116 … … 140 126 return Str::random($length); 141 127 } 128 142 129 }
Note:
See TracChangeset
for help on using the changeset viewer.