| Conditions | 3 |
| Paths | 2 |
| Total Lines | 51 |
| Code Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 18 | public function showWelcome() |
||
| 19 | { |
||
| 20 | |||
| 21 | if (Auth::user()) { |
||
| 22 | |||
| 23 | // $email = Auth::user()->email; |
||
| 24 | $userDetails = DB::table('users')->select('*')->where('id', Auth::user()->id)->get(); |
||
| 25 | foreach ($userDetails as $key => $value) { |
||
| 26 | $userDetailsArray = array(); |
||
|
|
|||
| 27 | $userDetailsArray = $value; |
||
| 28 | } |
||
| 29 | // print_r($userDetailsArray); |
||
| 30 | |||
| 31 | // $data['userDetailsArray']=$userDetailsArray; |
||
| 32 | |||
| 33 | } |
||
| 34 | /* |
||
| 35 | * get notofications,task notifications,global notifications ... |
||
| 36 | */ |
||
| 37 | $countUnreadMessages = DB::table('personal_conversations') |
||
| 38 | ->select(DB::raw('count(read_status) as unread_count')) |
||
| 39 | |||
| 40 | ->where('read_status','=',1) |
||
| 41 | ->where('to_user_id','=',Auth::user()->id)->first(); |
||
| 42 | |||
| 43 | $countUnreadGeneralMessages = DB::table('team_conversations_read_status') |
||
| 44 | ->select(DB::raw('count(read_status) as unread_count')) |
||
| 45 | |||
| 46 | ->where('read_status','=',1) |
||
| 47 | ->where('user_id','=',Auth::user()->id)->first(); |
||
| 48 | |||
| 49 | $countUnreadJoinMessages = DB::table('invitation_notification') |
||
| 50 | ->select(DB::raw('count(read_status) as unread_count')) |
||
| 51 | |||
| 52 | ->where('read_status','=',1) |
||
| 53 | |||
| 54 | ->where('invitation_notification.new_user', '!=', Auth::user()->id) |
||
| 55 | ->where('team_user','=',Auth::user()->id)->first(); |
||
| 56 | /* |
||
| 57 | * pass each notifcation count in array |
||
| 58 | */ |
||
| 59 | |||
| 60 | $data=array( |
||
| 61 | |||
| 62 | "unreadMessageCount"=>$countUnreadMessages["unread_count"], |
||
| 63 | "userDetailsArray"=>$userDetailsArray, |
||
| 64 | "unreadGeneralMessageCount"=>$countUnreadGeneralMessages["unread_count"], |
||
| 65 | "unreadJoinMessageCount"=>$countUnreadJoinMessages["unread_count"], |
||
| 66 | |||
| 67 | ); |
||
| 68 | return View::make('templates/home')->with("data",$data); |
||
| 69 | } |
||
| 72 |