@@ -8,8 +8,7 @@ discard block |
||
| 8 | 8 | use Illuminate\Foundation\Auth\User as Authenticatable; |
| 9 | 9 | use Illuminate\Support\Facades\Auth; |
| 10 | 10 | |
| 11 | -class User extends Authenticatable |
|
| 12 | -{ |
|
| 11 | +class User extends Authenticatable { |
|
| 13 | 12 | use Notifiable; |
| 14 | 13 | |
| 15 | 14 | /** |
@@ -47,14 +46,16 @@ discard block |
||
| 47 | 46 | 'updated_at' |
| 48 | 47 | ]; |
| 49 | 48 | |
| 50 | - public function thread() { |
|
| 49 | + public function thread() |
|
| 50 | + { |
|
| 51 | 51 | return $this->hasMany('App\Thread', 'user_id'); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * @return int |
| 56 | 56 | */ |
| 57 | - public function threadAnswered() { |
|
| 57 | + public function threadAnswered() |
|
| 58 | + { |
|
| 58 | 59 | return count( |
| 59 | 60 | Thread::where('status', true) |
| 60 | 61 | ->where('user_id', Auth::guard('web') |
@@ -4,8 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use Illuminate\Database\Eloquent\Model; |
| 6 | 6 | |
| 7 | -class Thread extends Model |
|
| 8 | -{ |
|
| 7 | +class Thread extends Model { |
|
| 9 | 8 | protected $table = 'threads'; |
| 10 | 9 | |
| 11 | 10 | protected $dates = [ |
@@ -13,19 +12,23 @@ discard block |
||
| 13 | 12 | 'updated_at' |
| 14 | 13 | ]; |
| 15 | 14 | |
| 16 | - public function topic() { |
|
| 15 | + public function topic() |
|
| 16 | + { |
|
| 17 | 17 | return $this->belongsTo('App\ThreadTopic', 'id_topic'); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - public function user() { |
|
| 20 | + public function user() |
|
| 21 | + { |
|
| 21 | 22 | return $this->belongsTo('App\User'); |
| 22 | 23 | } |
| 23 | 24 | |
| 24 | - public function doctor() { |
|
| 25 | + public function doctor() |
|
| 26 | + { |
|
| 25 | 27 | return $this->belongsTo('App\Doctor'); |
| 26 | 28 | } |
| 27 | 29 | |
| 28 | - public function trimStr(string $string) { |
|
| 30 | + public function trimStr(string $string) |
|
| 31 | + { |
|
| 29 | 32 | if(strlen($string) > 200) { |
| 30 | 33 | return substr($string, 0, 200).'...'; |
| 31 | 34 | } |
@@ -7,8 +7,7 @@ discard block |
||
| 7 | 7 | use App\Thread; |
| 8 | 8 | use App\ThreadTopic; |
| 9 | 9 | |
| 10 | -class ThreadAskController extends Controller |
|
| 11 | -{ |
|
| 10 | +class ThreadAskController extends Controller { |
|
| 12 | 11 | public function __construct() |
| 13 | 12 | { |
| 14 | 13 | $this->middleware('auth', ['except' => [ |
@@ -173,7 +172,8 @@ discard block |
||
| 173 | 172 | } |
| 174 | 173 | |
| 175 | 174 | |
| 176 | - private function currentUser() { |
|
| 175 | + private function currentUser() |
|
| 176 | + { |
|
| 177 | 177 | return Auth::guard('web')->user(); |
| 178 | 178 | } |
| 179 | 179 | |
@@ -181,7 +181,8 @@ discard block |
||
| 181 | 181 | * @param string $topic |
| 182 | 182 | * @return ThreadTopic|null |
| 183 | 183 | */ |
| 184 | - private function addTopic(string $topic) { |
|
| 184 | + private function addTopic(string $topic) |
|
| 185 | + { |
|
| 185 | 186 | $new = new ThreadTopic; |
| 186 | 187 | $new->topic_name = $topic; |
| 187 | 188 | if($new->save()) { |
@@ -196,7 +197,8 @@ discard block |
||
| 196 | 197 | * @param int $id |
| 197 | 198 | * @return bool |
| 198 | 199 | */ |
| 199 | - private function deleteTopic($id) { |
|
| 200 | + private function deleteTopic($id) |
|
| 201 | + { |
|
| 200 | 202 | $topic = ThreadTopic::find($id); |
| 201 | 203 | if($topic->delete()) { |
| 202 | 204 | return true; |