示例#1
0
 public function showMemberContacts()
 {
     $memberCollection = array();
     if (Auth::user()->isAdmin()) {
         $contacts = Contact::all();
     } else {
         $contacts = Contact::where('user_id', Auth::user()->id)->get();
         $memberCollection = MemberAPI::getmemberapiselect(Auth::user()->id);
         foreach ($memberCollection as $member) {
             if (!User::find($member->member_id)) {
                 $user = new User();
                 $user->id = $member->member_id;
                 $user->username = $member->username;
                 $user->name = $member->name;
                 $user->password = Hash::make(rand());
                 $user->active = 1;
                 $user->save();
             }
             $membercontacts = Contact::where('user_id', $member->member_id)->get();
             $contacts = $contacts->merge($membercontacts);
         }
         // return $contacts->toJson();
     }
     return View::make('contacts.member', compact('contacts', 'memberCollection'));
 }
示例#2
0
 public function getTree($id)
 {
     // if (!Request::ajax()) {
     // return array();
     // }
     if ($id == 0) {
         $id = Auth::user()->id;
     }
     $htmltree = MemberAPI::getAllDownline($id);
     return $htmltree;
 }
示例#3
0
 public function showHome($username)
 {
     // checkmemberexist
     $memberapi = MemberAPI::getMemberByUserName($username);
     if (!$memberapi) {
         return Redirect::to('https://www.gntclub.com/');
     }
     $member = User::find($memberapi->member_id);
     $page = Page::findBySlug('home')->published()->first();
     $cookie = Cookie::make('member_id', $member->member_id, 60);
     if ($page) {
         return View::make('pages.templates.home', compact('page', 'member'))->withCookie($cookie);
     } else {
         return View::make('layouts.unpublished');
     }
 }
示例#4
0
 public function doLogin()
 {
     // validate the info, create rules for the inputs
     $rules = array('username' => 'required', 'password' => 'required|alphaNum|min:6');
     // run the validation rules on the inputs from the form
     $validator = Validator::make(Input::all(), $rules);
     // if the validator fails, redirect back to the form
     if ($validator->fails()) {
         return Redirect::to('login')->withErrors($validator)->withInput(Input::except('password'));
         // send back the input (not the password) so that we can repopulate the form
     } else {
         // create our user data for the authentication
         $userdata = array('username' => Input::get('username'), 'password' => Input::get('password'), 'active' => 1);
         // attempt to do the login
         if (Auth::attempt($userdata, true)) {
             // validation successful!
             // redirect them to the secure section or whatever
             // Auth::user()->role;
             if (Auth::user()->isAdmin()) {
                 return Redirect::to(Auth::user()->roleString() . '/dashboard');
             } else {
                 $htmltree = MemberAPI::getmemberchilds(Auth::user()->id);
                 return Redirect::to(Auth::user()->roleString() . '/dashboard')->with('htmltree', $htmltree);
             }
         } else {
             // validation not successful, send back to form
             return Redirect::to('login')->withErrors('Email atau password yang Anda berikan salah, mohon mencoba kembali.');
         }
     }
 }