public function indexJson(Request $request, Group $group)
 {
     //dd($request);
     // load of actions between start and stop provided by calendar js
     if ($request->has('start') && $request->has('end')) {
         $actions = $group->actions()->where('start', '>', Carbon::parse($request->get('start')))->where('stop', '<', Carbon::parse($request->get('end')))->orderBy('start', 'asc')->get();
     } else {
         $actions = $group->actions()->orderBy('start', 'asc')->get();
     }
     $event = '';
     $events = '';
     foreach ($actions as $action) {
         $event['id'] = $action->id;
         $event['title'] = $action->name . ' (' . $group->name . ')';
         $event['description'] = $action->body . ' <br/> ' . $action->location;
         $event['body'] = $action->body;
         $event['summary'] = summary($action->body);
         $event['location'] = $action->location;
         $event['start'] = $action->start->toIso8601String();
         $event['end'] = $action->stop->toIso8601String();
         $event['url'] = action('ActionController@show', [$group->id, $action->id]);
         $event['color'] = $group->color();
         $events[] = $event;
     }
     return $events;
 }
Пример #2
0
 public static function updateGroups(Request $request)
 {
     $titles = $request::get('title');
     $ids = $request::get('id');
     $deleteId = $request::get('delete');
     $newtitle = $request::get('newtitle');
     $i = 0;
     if ($ids) {
         foreach ($ids as $id) {
             $group = Group::find($id);
             $group->title = $titles[$i];
             if (isset($deleteId[$i]) && $deleteId[$i] == $id) {
                 $group->delete();
             } else {
                 $group->save();
             }
             $i++;
         }
     }
     if ($newtitle) {
         $group = new Group();
         $group->title = $newtitle;
         $group->save();
     }
     return true;
 }
Пример #3
0
 public function axsave(Request $request)
 {
     //
     $response = array('status' => 'success', 'msg' => 'OK!');
     $rules = array('fname' => 'required', 'fremark' => 'required', 'femail' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         $response['status'] = "warning";
         $response['msg'] = $validator->messages()->toJson();
         return response()->json($response);
     } else {
         try {
             $gid = Input::get('fid');
             if ($gid != 'Neu') {
                 $group = Group::find($gid);
             } else {
                 $group = new Group();
             }
             $group->name = Input::get('fname');
             $group->remark = Input::get('fremark');
             $group->email = Input::get('femail');
             //$user = \App\User::find(1) ;
             $group->manager()->associate(Input::get('fmanager'));
             $group->save();
         } catch (\Illuminate\Database\QueryException $e) {
             $response['status'] = "danger";
             $response['msg'] = "Database error: " . $e->getMessage();
             return response()->json($response);
         }
         //return Response::json( $response );
         return response()->json($response);
     }
     //validatorf
 }
 public function listAuths($description)
 {
     if (!isset($description)) {
         return "bad";
     }
     $group = new Group();
     return $group->auths($description);
 }
Пример #5
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $group = new Group();
     $group->name = 'Projects';
     $group->officer_id = 1;
     $group->save();
     $group->members()->attach(1);
 }
 private static function createTestGroup()
 {
     $group = new Group();
     $group->name = 'Test123';
     $group->scout_group = 'Test_group123';
     $group->age_group = 'sudenpennut';
     $group_id = $group->save();
     return $group_id;
 }
Пример #7
0
 public function createGroup(Request $request)
 {
     $user = Auth::user();
     $group = new Group();
     $group->gname = $request->input('gname');
     $group->user_id = $user->id;
     $group->save();
     $group->members()->attach(array($user->id));
     //Adds user as member of group
     return Redirect::action('PagesController@dashboard');
 }
Пример #8
0
 public function testGroupCanBeDeleted()
 {
     $this->logIn();
     session()->set('admin', 1);
     $group = new Group();
     $group->name = 'RyhmäA';
     $group->scout_group = 'Lippulaiset';
     $group->age_group = 'Vuotiaat';
     $group->save();
     $this->visit('/groups/1')->press('Poista')->seePageIs('/groups')->dontSee('RyhmäA');
 }
Пример #9
0
 /**
  * Renders a embedable map
  */
 public function embed(Group $group)
 {
     $users = $group->users()->where('latitude', '<>', 0)->get();
     $actions = $group->actions()->where('start', '>=', Carbon::now())->where('latitude', '<>', 0)->get();
     // randomize users geolocation by a few meters
     foreach ($users as $user) {
         $user->latitude = $user->latitude + mt_rand(0, 10) / 10000;
         $user->longitude = $user->longitude + mt_rand(0, 10) / 10000;
     }
     return view('groups.map_embed')->with('tab', 'map')->with('group', $group)->with('users', $users)->with('actions', $actions)->with('latitude', 50.8503396)->with('longitude', 4.3517103);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request, Group $group)
 {
     $discussion = new Discussion();
     $discussion->name = $request->input('name');
     $discussion->body = $request->input('body');
     $discussion->total_comments = 1;
     // the discussion itself is already a comment
     $discussion->user()->associate(Auth::user());
     if (!$group->discussions()->save($discussion)) {
         // Oops.
         return redirect()->action('DiscussionController@create', $group->id)->withErrors($discussion->getErrors())->withInput();
     }
     flash()->info(trans('messages.ressource_created_successfully'));
     return redirect()->action('DiscussionController@show', [$group->id, $discussion->id]);
 }
Пример #11
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     $title = 'Join a new group';
     $groups = Group::allPaginatedGroups();
     $tagline = "Join a New Group";
     return view('inspina.groups.search', compact('groups', 'title', 'tagline'));
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(0, 30) as $index) {
         Group::create(['name' => $faker->sentence(1), 'sport_id' => $faker->biasedNumberBetween(0, 10), 'description' => $faker->sentence(10)]);
     }
 }
Пример #13
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Group::create(["designation" => "Buraca02", "localization" => "Buraca", "creation_date" => "37262"]);
     Group::create(["designation" => "Buraca04", "localization" => "Buraca", "creation_date" => "38333"]);
     Group::create(["designation" => "Buraca08", "localization" => "Buraca", "creation_date" => "39425"]);
     Group::create(["designation" => "Buraca12", "localization" => "Buraca", "creation_date" => "40965"]);
     Group::create(["designation" => "Cacem10", "localization" => "Cacem", "creation_date" => "40195"]);
     Group::create(["designation" => "Caparide07", "localization" => "Tires", "creation_date" => "39131"]);
     Group::create(["designation" => "Entroncamento13", "localization" => "Entroncamento", "creation_date" => "41294"]);
     Group::create(["designation" => "Laranjeiras09", "localization" => "Laranjeiras", "creation_date" => "39873"]);
     Group::create(["designation" => "Lavradio07", "localization" => "Lavradio", "creation_date" => "41315"]);
     Group::create(["designation" => "Loures10", "localization" => "Loures", "creation_date" => "40216"]);
     Group::create(["designation" => "Madrona05 e Tires05", "localization" => "Madorna", "creation_date" => "38389"]);
     Group::create(["designation" => "MtA10", "localization" => "MtA", "creation_date" => "40216"]);
     Group::create(["designation" => "RM07", "localization" => "RM", "creation_date" => "39425"]);
     Group::create(["designation" => "SDR03", "localization" => "SDR", "creation_date" => "37633"]);
     Group::create(["designation" => "SDR10", "localization" => "SDR", "creation_date" => "40153"]);
     Group::create(["designation" => "SJB08", "localization" => "SJB", "creation_date" => "39509"]);
     Group::create(["designation" => "SJB12", "localization" => "SJB", "creation_date" => "40965"]);
     Group::create(["designation" => "Tires05", "localization" => "Tires", "creation_date" => "38382"]);
     Group::create(["designation" => "VN08", "localization" => "VN", "creation_date" => "39138"]);
     Group::create(["designation" => "VN11", "localization" => "VN", "creation_date" => "40587"]);
     Group::create(["designation" => "Cacem08", "localization" => "Cacem", "creation_date" => "25569"]);
     Group::create(["designation" => "CAboboda14", "localization" => "Conceição da Aboboda", "creation_date" => "41672"]);
     Group::create(["designation" => "SJB14", "localization" => "SJB", "creation_date" => "41665"]);
     Group::create(["designation" => "VN14", "localization" => "VN", "creation_date" => "41679"]);
 }
Пример #14
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $user = User::findOrFail($id);
     $groups = Group::all(['id', 'name']);
     $categories = Category::all(['id', 'name']);
     return view('users.edit', compact('user', 'groups', 'categories'));
 }
Пример #15
0
 /**
  * Register any application authentication / authorization services.
  *
  * @param  \Illuminate\Contracts\Auth\Access\Gate  $gate
  * @return void
  */
 public function boot(GateContract $gate)
 {
     $this->registerPolicies($gate);
     $gate->define('update-general', function ($user, $model) {
         return Group::perm_update($user, $model);
     });
 }
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // we expect a url in the form /groups/{group_id}
     if ($request->segment(1) == 'groups') {
         if ($this->auth->guest()) {
             $group = \App\Group::findOrFail($request->segment(2));
             if ($group->isPublic()) {
                 return $next($request);
             } else {
                 return redirect()->back()->with('message', trans('messages.not_allowed'));
             }
         } else {
             $group = \App\Group::findOrFail($request->segment(2));
             if ($group->isPublic()) {
                 return $next($request);
             } elseif ($group->isMember()) {
                 return $next($request);
             } elseif ($request->user()->isAdmin()) {
                 return $next($request);
                 // user is admin, and sees everything, fine (at least in sync with current policies for admins)
             } else {
                 return redirect()->back()->with('message', trans('messages.not_allowed'));
             }
         }
     } else {
         return redirect()->back()->with('message', 'Are you in a group at all !? (url doesnt start with group/something). This is a bug');
     }
 }
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle(Mailer $mail)
 {
     $group = $this->ticket->group_id;
     $customers = Group::where('id', $group)->first()->customers()->get();
     $_customers = [];
     foreach ($customers as $customer) {
         $_customers[] = $customer->id;
     }
     $sys_name = Settings::where('name', 'sys_name')->first();
     $user = User::whereIn('customer_id', $_customers)->get();
     foreach ($user as $_user) {
         $mail->send('emails.updateticket', ['user' => $_user, 'ticket' => $this->ticket, 'response' => $this->response, 'sys_name' => $sys_name], function ($m) use($_user) {
             $m->to($_user->email, $_user->first_name . ' ' . $_user->last_name)->subject('Ticket updated - ' . $this->ticket->track_id . ' [' . $this->ticket->status->name . ']');
             if (count($this->response->attachments()->get()) > 0) {
                 foreach ($this->response->attachments as $attachment) {
                     $m->attach(storage_path() . '/attachments/' . $this->ticket->id . '/' . $attachment->name);
                 }
             }
         });
     }
     // Cleanup variables
     unset($this->ticket);
     unset($this->response);
     unset($group);
     unset($customers);
     unset($user);
     unset($sys_name);
     unset($_customers);
 }
Пример #18
0
 public function index()
 {
     $groups = Group::with(['users' => function ($query) {
         $query->where('active', 1);
     }])->orderBy('name', 'ASC')->get();
     return view('index', compact('groups'));
 }
 public function testUserCanBeRemovedFromTheGroup()
 {
     $this->logIn();
     $group = new Group();
     $group->name = 'TestiRyhmä';
     $group->scout_group = 'Lippukunta';
     $group->age_group = 'Ikäryhmä';
     $group->save();
     $user = new User();
     $user->id = '23';
     $user->membernumber = '2312334212';
     $user->firstname = 'Liisa';
     $user->lastname = 'Saarenmaa';
     $user->save();
     $this->visit('/groups/1/users')->press('Lisää ryhmän jäsen')->see('Liisa')->press('Poista')->dontSee('Poista');
 }
 public function getAssignedGroupsToProject($projectId)
 {
     $groups = Group::whereHas('projects', function ($q) use($projectId) {
         $q->where('project_id', $projectId);
     })->paginate(5);
     return $groups;
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $user = User::findOrFail($id);
     $groups = Group::get()->lists('name', 'id');
     $userGroups = $user->groups->lists('id');
     return view('user.edit', compact('user', 'groups', 'userGroups'));
 }
Пример #22
0
 public function destroy($id)
 {
     $group = \App\Group::FindOrFail($id);
     $group->delete();
     \Session::flash('flash_message', 'Group has been deleted.');
     return redirect('groups');
 }
Пример #23
0
 /**
  * set up start
  */
 public function setUp()
 {
     parent::setUp();
     Session::start();
     // $this->mock = \Mockery::mock('\App\Group');
     $this->id_test = Group::all()->first()->id;
 }
 public function destroy($groupId)
 {
     $group = Group::findOrFail($groupId);
     $this->authorize('destroy', $group);
     $group->delete();
     return Redirect::to(route('group.index'))->with(['success_message' => 'Deleted!']);
 }
Пример #25
0
 /**
  * @param null $user
  * @param int $howMany
  * @return mixed
  */
 public function groupsForUser($user = null, $howMany = 1)
 {
     if ($user != null) {
         return Group::where('user_id', $user->id)->simplePaginate($howMany);
     }
     return Group::where('user_id', $this->user()->id)->simplePaginate($howMany);
 }
Пример #26
0
 public function store(Request $request)
 {
     $user = Auth::user();
     if ($user->is('admin|groupadmin')) {
         if ($request->hasFile('file')) {
             $filename = $request->file('file')->getClientOriginalName();
             if ($request->file('file')->move(sys_get_temp_dir(), $filename)) {
                 $path = sys_get_temp_dir() . '/' . $filename;
                 if ($request->has('user_id')) {
                     $target = User::findOrFail($request->input('user_id'));
                     $folder = $target->username;
                     $ret = redirect(url('admin/show/' . $target->id));
                 } else {
                     if ($request->has('group_id')) {
                         $group = Group::findOrFail($request->input('group_id'));
                         $folder = $group->name;
                         $ret = redirect(url('admin/groups/'));
                     }
                 }
                 if ($user->testAccess($folder)) {
                     Cloud::loadFile($path, $folder, $filename);
                 } else {
                     abort(403);
                 }
                 unlink($path);
             }
         }
         return $ret;
     } else {
         abort(403);
     }
 }
Пример #27
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!Auth::user()) {
         return redirect('auth/login');
     }
     $groupall = Auth::user()->group()->get();
     $allowed_routes = array();
     foreach ($groupall as $key => $value) {
         $feature = Group::find($value->id)->feature()->get();
         foreach ($feature as $key_fea => $val_fea) {
             $val_fea_j = json_decode($val_fea->url_action);
             if ($val_fea_j != NULL) {
                 foreach ($val_fea_j as $k_valfea => $v_valfea) {
                     array_push($allowed_routes, $v_valfea);
                 }
             } else {
                 array_push($allowed_routes, $val_fea->url_action);
             }
         }
     }
     //view()->share('sidebar', ($this->showSidebar($allowed_routes)));
     App::singleton('allowed_routes', function () use($allowed_routes) {
         return $allowed_routes;
     });
     /*App::after(function ($request, $response) {
     		// Mencegah Kembali Login Setelah Logout dengan Menekan Tombol Back pada Browser
     		$response->headers->set("Cache-Control", "no-cache,no-store, must-revalidate");
     		$response->headers->set("Pragma", "no-cache"); //HTTP 1.0
     		$response->headers->set("Expires", " Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
     		});*/
     view()->share('allowed_routes', $allowed_routes);
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // exit();
     // First make sure there is an active session
     // dd(debug_print_backtrace(2));
     // dd(Sentry::check());
     if (!Sentry::check()) {
         // return $next($request);
         exit('tidak login');
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             return redirect()->guest(route('sentinel.login'));
         }
     }
     // Now check to see if the current user has the 'admin' permission
     // dd(get_class(Sentry::getUser()));
     // dd(Sentry::getUser()->hasAccess('admin'));//Sentinel\Models\User
     if (Sentry::getUser()->hasAccess('admin')) {
         dd('admin');
         return $next($request);
     }
     // dd($request->route()->getActionName());//"App\Http\Controllers\ExcelController@getIndex"
     if (!Sentry::getUser()->hasAccess('admin')) {
         // echo 'masukkk bukan admin<br>';
         // dd(\Sentry::getUser()->getGroups()[0]->pivot->group_id);
         //ambil group_id lewat user_id -> lewat pivot users_group
         $group_id = \Sentry::getUser()->getGroups()[0]->pivot->group_id;
         // dd($group_id);
         //melalui group model dengan id diatas => untuk mengambil akses menu  ( menghasilkan list akses menu)
         $akses = Group::find($group_id)->akses()->get()->toArray();
         // $akses = Group::find($group_id)->akses->get()->toArray();
         // dd($akses);
         // echo $akses;
         $currentRoute = $request->route()->getActionName();
         // dd($currentRoute).'-----<br>';
         foreach ($akses as $key => $value) {
             $action = $value['controller'] . '@' . $value['controller_method'];
             // $action=$value['controller'];
             if ($action == $currentRoute && $value['akses'] == 1) {
                 // var_dump( $currentRoute == $action );
                 return $next($request);
             }
         }
         return response('Unauthorized.', 401);
     }
     // dd(Sentry::getUser()->hasAccess('admin'));
     // dd(Sentry::getId());
     // dd(Sentry::getGroups());
     // All clear - we are good to move forward
     // return $next($request);
     if ($request->ajax()) {
         dd('ajaxx');
         return response('Unauthorized.', 401);
     } else {
         Session::flash('error', trans('Sentinel::users.noaccess'));
         return redirect()->route('sentinel.login');
     }
 }
 public function remove($id, Request $request)
 {
     $group = Group::findOrFail($id);
     $user = User::findOrFail($request->input('userId'));
     $group->users()->detach($user);
     $group->save();
     return redirect()->back();
 }
Пример #30
0
 public function getGroup($groupId)
 {
     $group = Group::find($groupId);
     if (!is_null($group)) {
         return $group->toArray();
     }
     return false;
 }