@@ -21,28 +21,28 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | public function updateAvatar(Request $request) |
| 23 | 23 | { |
| 24 | - $isValid = $request->file('avatar')->isValid(); |
|
| 25 | - if($isValid){ |
|
| 26 | - $extension = $request->file('avatar')->extension(); |
|
| 27 | - }else{ |
|
| 24 | + $isValid=$request->file('avatar')->isValid(); |
|
| 25 | + if ($isValid) { |
|
| 26 | + $extension=$request->file('avatar')->extension(); |
|
| 27 | + } else { |
|
| 28 | 28 | return ResponseModel::err(1005); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - $allow_extension = ['jpg','png','jpeg','gif','bmp']; |
|
| 32 | - if($isValid && in_array($extension,$allow_extension)){ |
|
| 33 | - $path = $request->file('avatar')->store('/static/img/avatar','NOJPublic'); |
|
| 31 | + $allow_extension=['jpg', 'png', 'jpeg', 'gif', 'bmp']; |
|
| 32 | + if ($isValid && in_array($extension, $allow_extension)) { |
|
| 33 | + $path=$request->file('avatar')->store('/static/img/avatar', 'NOJPublic'); |
|
| 34 | 34 | |
| 35 | - $user = Auth::user(); |
|
| 36 | - $old_path = $user->avatar; |
|
| 37 | - if($old_path != '/static/img/avatar/default.png' && $old_path != '/static/img/avatar/noj.png'){ |
|
| 35 | + $user=Auth::user(); |
|
| 36 | + $old_path=$user->avatar; |
|
| 37 | + if ($old_path!='/static/img/avatar/default.png' && $old_path!='/static/img/avatar/noj.png') { |
|
| 38 | 38 | Storage::disk('NOJPublic')->delete($old_path); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - $user->avatar = '/'.$path; |
|
| 41 | + $user->avatar='/'.$path; |
|
| 42 | 42 | $user->save(); |
| 43 | 43 | |
| 44 | 44 | return ResponseModel::success(200, null, '/'.$path); |
| 45 | - }else{ |
|
| 45 | + } else { |
|
| 46 | 46 | return ResponseModel::err(1005); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | $isValid = $request->file('avatar')->isValid(); |
| 25 | 25 | if($isValid){ |
| 26 | 26 | $extension = $request->file('avatar')->extension(); |
| 27 | - }else{ |
|
| 27 | + } else{ |
|
| 28 | 28 | return ResponseModel::err(1005); |
| 29 | 29 | } |
| 30 | 30 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $user->save(); |
| 43 | 43 | |
| 44 | 44 | return ResponseModel::success(200, null, '/'.$path); |
| 45 | - }else{ |
|
| 45 | + } else{ |
|
| 46 | 46 | return ResponseModel::err(1005); |
| 47 | 47 | } |
| 48 | 48 | |
@@ -20,20 +20,20 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | public function __invoke(Request $request) |
| 22 | 22 | { |
| 23 | - if(!$request->has('search_key')){ |
|
| 23 | + if (!$request->has('search_key')) { |
|
| 24 | 24 | return ResponseModel::err(1003); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - $search_key = strtoupper($request->input('search_key')); |
|
| 27 | + $search_key=strtoupper($request->input('search_key')); |
|
| 28 | 28 | $problem=new ProblemModel(); |
| 29 | - $prob_details = $problem->detail($search_key); |
|
| 30 | - if(!is_null($prob_details)){ |
|
| 29 | + $prob_details=$problem->detail($search_key); |
|
| 30 | + if (!is_null($prob_details)) { |
|
| 31 | 31 | if ($problem->isBlocked($prob_details["pid"])) { |
| 32 | 32 | return ResponseModel::err(403); |
| 33 | 33 | } |
| 34 | - $problem_url = route('problem_detail',['pcode' => $search_key]); |
|
| 34 | + $problem_url=route('problem_detail', ['pcode' => $search_key]); |
|
| 35 | 35 | return ResponseModel::success(200, null, $problem_url); |
| 36 | - }else{ |
|
| 36 | + } else { |
|
| 37 | 37 | return ResponseModel::err(3001); |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | } |
| 34 | 34 | $problem_url = route('problem_detail',['pcode' => $search_key]); |
| 35 | 35 | return ResponseModel::success(200, null, $problem_url); |
| 36 | - }else{ |
|
| 36 | + } else{ |
|
| 37 | 37 | return ResponseModel::err(3001); |
| 38 | 38 | } |
| 39 | 39 | } |