public function getManageUsers()
 {
     $query = User::whereHas('group', function ($query) {
         $query->where('admin', '1');
     })->orderBy('id', 'asc')->paginate(10);
     $this->layout->content = View::make('admin.manage_users')->with('users', $query);
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     if (\Input::get('month')) {
         $data = \Input::all();
         $date = $data['year'] . '-' . $data['month'] . '-01';
         $emp_type = $data['emp_type'];
         $client = \Input::get('clientId');
         $payType = \Input::get('payType');
         $empId = \Input::get('empId');
         if ($emp_type == 'inhouse') {
             $uId = \Auth::user()->id;
             $emp = \User::whereHas('empJobDetail', function ($q) use($uId, $date) {
                 $q->where('emp_type', '=', 'inhouse');
                 $q->whereHas('branch', function ($s) use($uId) {
                     $s->where('branch_id', '=', $uId);
                 });
                 $q->whereHas('attend', function ($a) use($date) {
                     $a->where('attend_date', '=', $date);
                 });
             })->paginate(20);
         } elseif ($emp_type == 'outsource' && $client != '') {
             $emp = \User::whereHas('empJobDetail', function ($q) use($client, $date) {
                 $q->whereHas('attend', function ($a) use($date) {
                     $a->where('attend_date', '=', $date);
                 });
                 $q->where('emp_type', '=', 'outsource');
                 $q->where('client_id', '=', $client);
             })->paginate(20);
         }
         return \View::make('branch/salary.manage_salary')->with('emp', $emp)->with('date', $date)->with(\Input::flash());
     } else {
         return \View::make('branch/salary.manage_salary');
     }
 }
 public function notify()
 {
     // What notification type is this
     if ($this->timeRemaining->hours == 24) {
         $notificationType = NotificationType::TMinus24HoursEmail;
     } elseif ($this->timeRemaining->hours == 3) {
         $notificationType = NotificationType::TMinus3HoursEmail;
     } else {
         $notificationType = NotificationType::TMinus1HourEmail;
     }
     // grab all users with this particular notification
     $usersToNotify = User::whereHas('notification', function ($q) use($notificationType) {
         $q->where('notification_type_id', $notificationType);
     })->with('notifications.notification_type')->get();
     // Prepare to send
     $missionCountdownMailer = new MissionCountdownMailer();
     $missionCountdownMailer->send($usersToNotify, $this->nextMission, $this->timeRemaining, $notificationType);
 }
Example #4
0
 public function view(\User $current = null)
 {
     $user = \Auth::user();
     $users = array();
     $messages = array();
     $senders = \User::whereHas('sent', function ($query) use($user) {
         $query->where('to_id', $user->id);
     })->orWhereHas('received', function ($query) use($user) {
         $query->where('from_id', $user->id);
     })->orderBy('created_at', 'desc')->get();
     if (!$current && $senders->count()) {
         $current = $senders->first();
     }
     if ($current) {
         $messages = $current->sent()->where('to_id', $user->id)->orWhere(function ($query) use($current, $user) {
             $query->where('to_id', $current->id)->where('from_id', $user->id);
         })->orderBy('created_at', 'desc')->get();
     }
     return View::make('message::mailbox.mailbox', compact('user', 'senders', 'messages', 'current'));
 }
 public function testHasManyHas()
 {
     $author1 = User::create(array('name' => 'George R. R. Martin'));
     $author1->books()->create(array('title' => 'A Game of Thrones', 'rating' => 5));
     $author1->books()->create(array('title' => 'A Clash of Kings', 'rating' => 5));
     $author2 = User::create(array('name' => 'John Doe'));
     $author2->books()->create(array('title' => 'My book', 'rating' => 2));
     User::create(array('name' => 'Anonymous author'));
     Book::create(array('title' => 'Anonymous book', 'rating' => 1));
     $authors = User::has('books')->get();
     $this->assertCount(2, $authors);
     $this->assertEquals('George R. R. Martin', $authors[0]->name);
     $this->assertEquals('John Doe', $authors[1]->name);
     $authors = User::has('books', '>', 1)->get();
     $this->assertCount(1, $authors);
     $authors = User::has('books', '<', 5)->get();
     $this->assertCount(3, $authors);
     $authors = User::has('books', '>=', 2)->get();
     $this->assertCount(1, $authors);
     $authors = User::has('books', '<=', 1)->get();
     $this->assertCount(2, $authors);
     $authors = User::has('books', '=', 2)->get();
     $this->assertCount(1, $authors);
     $authors = User::has('books', '!=', 2)->get();
     $this->assertCount(2, $authors);
     $authors = User::has('books', '=', 0)->get();
     $this->assertCount(1, $authors);
     $authors = User::has('books', '!=', 0)->get();
     $this->assertCount(2, $authors);
     $authors = User::whereHas('books', function ($query) {
         $query->where('rating', 5);
     })->get();
     $this->assertCount(1, $authors);
     $authors = User::whereHas('books', function ($query) {
         $query->where('rating', '<', 5);
     })->get();
     $this->assertCount(1, $authors);
 }
Example #6
0
 public function form($slug)
 {
     // Retrive Project Details
     $project = Project::where('slug', $slug)->first();
     // Get all developer users
     $developers = User::whereHas('roles', function ($q) {
         $q->where('key', 'developer');
     })->get();
     // Get all QC users
     $qc = User::whereHas('roles', function ($q) {
         $q->where('key', 'qc');
     })->get();
     // Check if the project is existing.
     if ($project) {
         return View::make('projects.form')->with('project', $project)->with('developers', $developers)->with('qcs', $qc);
     } else {
         return Response::make('Unauthorized', 401);
     }
 }
Example #7
0
            $q->where('key', '=', $token_key);
        })->firstOrFail();
    } catch (ModelNotFoundException $e) {
        $app->halt(401, 'Gebruiker niet gevonden');
    }
    echo $user->educationLevel;
});
$app->post('/user/mindmap', function () use($app) {
    $app->response()->header('Content-Type', 'application/json');
    $token_key = $app->request->headers->get('Authorization');
    if (!$token_key) {
        $app->halt(401, 'no token');
    }
    try {
        $user = User::whereHas('token', function ($q) use($token_key) {
            $q->where('key', '=', $token_key);
        })->firstOrFail();
    } catch (ModelNotFoundException $e) {
        $app->halt(401, 'Gebruiker niet gevonden');
    }
    if (!$user->mindmap) {
        $mindmap = new Mindmap();
        $mindmap->mindmap = $app->request->getBody();
        $mindmap->user()->associate($user);
        $mindmap->save();
    }
    echo true;
});
$app->get('/user/mindmap(/:token)', function ($token = null) use($app) {
    $app->response()->header('Content-Type', 'text/html');
    $token_key = $app->request->headers->get('Authorization');
 /**
  * Remove the specified resource from storage.
  *
  * 
  * @return Response
  */
 public function search()
 {
     $field = \Input::get('f');
     if ($value = \Input::get('v')) {
         if ($field == 'username') {
             $emp = \User::where('username', '=', "{$value}")->where('profilesId', '=', 4)->paginate(20);
         }
         if ($field == 'email') {
             $emp = \User::where('email', '=', "{$value}")->where('profilesId', '=', 4)->paginate(20);
         }
         if ($field == 'name') {
             // where condition we are checking in employee table of relation
             $emp = \User::whereHas('employee', function ($q) use($value) {
                 $q->where('firstname', 'like', "%{$value}%");
             })->where('profilesId', '=', 4)->paginate(20);
         }
         if ($field == 'mobile') {
             //where condition we are cheking in contact table of relation table
             $emp = \User::whereHas('contact', function ($q) use($value) {
                 $q->where('mobile', '=', "{$value}");
             })->where('profilesId', '=', 4)->paginate(20);
         }
         return \View::make('admin/emp.search_emp')->withInput(\Input::flash())->with('list', $emp);
     } else {
         if ($field == 'branch') {
             $branch_id = \Input::get('branchId');
             $client_id = \Input::get('clientId');
             if ($branch_id) {
                 $validate = \Validator::make(array('branch' => $branch_id), array('branch' => 'required|numeric'));
                 if ($validate->fails()) {
                     return \View::make('admin/emp.search_emp')->withErrors($validate)->withInput(\Input::flash())->with('list', array());
                 }
                 if ($client_id == 'in-house') {
                     $emp = \User::whereHas('empJobDetail', function ($q) use($branch_id) {
                         $q->where('emp_type', '=', 'inhouse');
                         $q->whereHas('branch', function ($s) use($branch_id) {
                             $s->where('branch_id', '=', $branch_id);
                         });
                     })->paginate(20);
                     return \View::make('admin/emp.search_emp')->withInput(\Input::flash())->with('list', $emp);
                 } else {
                     $valid = \Validator::make(array('client' => $client_id), array('client' => 'required|numeric'));
                     if ($valid->fails()) {
                         return \View::make('admin/emp.search_emp')->withErrors($valid)->withInput(\Input::flash())->with('list', array());
                     } else {
                         $emp = \User::whereHas('empJobDetail', function ($q) use($client_id) {
                             $q->where('emp_type', '=', 'outsource');
                             $q->where('client_id', '=', $client_id);
                         })->paginate(20);
                         return \View::make('admin/emp.search_emp')->withInput(\Input::flash())->with('list', $emp);
                     }
                 }
             }
         }
         if ($field == 'all') {
             $emp = \User::where('profilesId', '=', 4)->paginate(20);
             return \View::make('admin/emp.search_emp')->withInput(\Input::flash())->with('list', $emp);
         } else {
             return \View::make('admin/emp.search_emp')->withInput(\Input::flash())->with('list', array());
         }
     }
 }
 /**
  *	Invitation Token
  *	Get related models.
  *
  *	@param	string	$token
  */
 public static function withinvitation($token)
 {
     # Return user and account
     return [User::whereHas('accounts', function ($q) use($token) {
         $q->where('account_user.invitation_token', $token);
     })->first(), Account::whereHas('users', function ($q) use($token) {
         $q->where('account_user.invitation_token', $token);
     })->first()];
 }
Example #10
0
 public function show_users()
 {
     $users = User::whereHas('roles', function ($q) {
         //выборка всех пользователей с ролью member
         $q->where('name', 'member');
     })->orderBy('id', 'DESC')->paginate(5);
     return View::make('admin.user.index')->withUsers($users);
 }
Example #11
0
 public static function listStorytellers()
 {
     return User::whereHas('permissions', function ($q) {
         $q->whereHas('definition', function ($q) {
             $q->where('name', 'Storyteller');
         });
     })->get();
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $uId = \Auth::user()->id;
     $month = \Input::get('month');
     $year = \Input::get('year');
     $emp_type = \Input::get('emp_type');
     $client = \Input::get('clientId');
     $empty = \User::where('id', '=', 0)->paginate(20);
     if (preg_match("/^(0[1-9]|1[0-2])\$/", $month) && preg_match("/^[0-9]{4}\$/", $year) && $emp_type) {
         $date = "{$year}-{$month}-01";
         if ($emp_type == 'outsource') {
             if (is_numeric($client)) {
                 $check = \Friends::where('child_id', '=', $client)->where('parent_id', '=', $uId)->first();
                 if ($check) {
                     $emps = \User::whereHas('empJobDetail', function ($q) use($client) {
                         $q->where('emp_type', '=', 'outsource');
                         $q->where('client_id', '=', $client);
                     })->get();
                     // get selected ids in array format
                     $ids = array_pluck($emps, 'id');
                     if ($ids) {
                         foreach ($ids as $id) {
                             if (\EmpAttendance::where('emp_id', '=', $id)->where('attend_date', '=', "{$date}")->first()) {
                                 // skip
                             } else {
                                 \EmpAttendance::insert(array('emp_id' => $id, 'attend_date' => $date));
                             }
                         }
                         $employees = \EmpAttendance::whereIn('emp_id', $ids)->where('attend_date', '=', "{$date}")->paginate(20);
                         return \View::make('branch/attendance.emp_attendance')->with('list', $employees)->with(\Input::flash());
                     } else {
                         return \View::make('branch/attendance.emp_attendance')->with('list', $empty)->with(\Input::flash());
                     }
                 } else {
                     return \View::make('branch/attendance.emp_attendance')->with('list', $empty)->with(\Input::flash());
                 }
             }
         } else {
             $emps = \User::whereHas('empJobDetail', function ($q) use($uId) {
                 $q->whereHas('branch', function ($s) use($uId) {
                     $s->where('branch_id', '=', $uId);
                 })->where('emp_type', '=', 'inhouse');
             })->get();
             $ids = array_pluck($emps, 'id');
             if ($ids) {
                 foreach ($ids as $id) {
                     if (\EmpAttendance::where('emp_id', '=', $id)->where('attend_date', '=', "{$date}")->first()) {
                         // skip
                     } else {
                         \EmpAttendance::insert(array('emp_id' => $id, 'attend_date' => $date));
                     }
                 }
                 $employees = \EmpAttendance::whereIn('emp_id', $ids)->where('attend_date', '=', "{$date}")->paginate(20);
                 return \View::make('branch/attendance.emp_attendance')->with('list', $employees)->with(\Input::flash());
             } else {
                 return \View::make('branch/attendance.emp_attendance')->with('list', $empty)->with(\Input::flash());
             }
         }
     } else {
         return \View::make('branch/attendance.emp_attendance')->with('list', $empty)->with(\Input::flash());
     }
 }
Example #13
0
 public function seedBlogPost()
 {
     $blogRepo = App::make('BlogRepository');
     $faker = Faker\Factory::create();
     foreach ($blogRepo->getAllPost()->get() as $post) {
         $blogRepo->deleteBlogPost($post->id);
     }
     $user = User::whereHas('roles', function ($q) {
         $q->whereName('Editor');
     })->orderBy(DB::raw('RAND()'))->first();
     $tags = Tag::orderBy(DB::raw('RAND()'))->take(rand(2, 4))->lists('id');
     $body = "";
     foreach ($faker->paragraphs(rand(5, 10)) as $p) {
         $body .= $p . "\n";
     }
     $nPosts = 10;
     $posts = [];
     for ($i = 0; $i < $nPosts; $i++) {
         $post = ['title' => $faker->sentence(rand(2, 5)), 'body' => $body, 'user' => $user, 'hero_file_url' => $faker->imageUrl(1024, 768, 'food'), 'tags' => $tags, 'status' => 'Publish', 'post_type' => $blogRepo->getPostType('post')->id, 'created_at' => $faker->dateTimeBetween('-3 years', 'now')];
         if (rand(0, 10) > 5) {
             $post['excerpt'] = $faker->paragraph(rand(1, 3));
         }
         $post = $blogRepo->createBlogPost($post);
         array_push($posts, $post);
     }
     return $posts;
 }