function updateGroup($id)
{
    $app = Slim\Slim::getInstance();
    $json = decodeJsonOrFail($app->request->getBody());
    $group = Group::findOrFail($id);
    $group->update($json);
    echo $group->toJson();
}
Example #2
0
 /**
  * Update the specified group in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $group = Group::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Group::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $group->update($data);
     return Redirect::route('groups.index');
 }
Example #3
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $user = User::findOrFail($this->argument('username'));
     $group = Group::findOrFail($this->argument('group'));
     $moderator = new GroupModerator();
     $moderator->group()->associate($group);
     $moderator->user()->associate($user);
     $moderator->type = $this->option('admin') ? 'admin' : 'moderator';
     $moderator->save();
     $this->info($user->name . ' is now moderator of ' . $group->urlname);
 }
function sendMessageToGroup($id)
{
    $app = Slim\Slim::getInstance();
    $group = Group::findOrFail($id);
    $json = decodeJsonOrFail($app->request->getBody());
    if (!isset($json['from'])) {
        $json['from'] = null;
    }
    if (!isset($json['from_user_id'])) {
        $json['from_user_id'] = null;
    }
    $message = new Message($json);
    $message->group()->associate($group);
    $message->save();
    echo $message->toJson();
}
 public function getGroup($group, $limit = 20, $page = 0)
 {
     if (!$this->auth) {
         return $this->error('not authorized', 401);
     }
     if (!$this->user->isDev() or !$this->user->isHax() or !$this->user->isGroup($group)) {
         return $this->error('not authorized', 401);
     }
     try {
         $group = Group::findOrFail($group);
         $limit = $limit > 50 ? 50 : $limit;
         $offset = $page <= 0 ? 0 : $limit * $page;
         $notifications = $group->notifications()->take($limit)->skip($offset);
         return $this->response($notifications->get());
     } catch (ModelNotFoundException $e) {
         return $this->error('group not found', 404);
     }
 }
Example #6
0
 public function edit($id)
 {
     $groupbyid = Group::findOrFail($id);
     $groupbyid = ['groupbyid' => $groupbyid];
     return View::make('group.edit', $groupbyid)->withTitle("Ubah Group");
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroygroup($id)
 {
     $group = Group::findOrFail($id);
     $group->delete();
     return Redirect::action('GroupController@index')->with('success', Lang::get('groups.delete_success'));
 }
 public function deleteAction()
 {
     try {
         $form = new GroupForm();
         if ($form->isValidForDelete()) {
             $group = Group::findOrFail(Input::get("id"));
             $group->delete();
         }
         //return Redirect::route("group/index");
     } catch (\Illuminate\Database\QueryException $e) {
         //001 Codigo error
     }
     return Redirect::route("group/index");
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     try {
         $group = Group::findOrFail($id);
         //prepare the meeting time for user friendly display
         $meetingTime = substr($group->meeting_time, 0, 1) == '0' ? substr($group->meeting_time, 1, 1) : substr($group->meeting_time, 0, 2);
         $group->meeting_time = $meetingTime . ':' . substr($group->meeting_time, -2, 2);
         $nextMeeting = $this->determineNextMeetingDate($group);
         if (Request::wantsJson()) {
             return Response::json(['group' => $group, 'nextMeeting' => $nextMeeting->toFormattedDateString()]);
         } else {
             return View::make('groups.show')->with(['group' => $group, 'nextMeeting' => $nextMeeting->toFormattedDateString()]);
         }
     } catch (Exception $e) {
         Log::error('Failed to find a specific record', array(404, "group: " . $group));
         App::abort(404);
         //this goes directly to the missing method in global.php
     }
 }
Example #10
0
 /**
  * Update the specified member in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $member = Member::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Member::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     if (Input::get('branch_id') != null) {
         $branch = Branch::findOrFail(Input::get('branch_id'));
         $member->branch()->associate($branch);
     }
     if (Input::get('group_id') != null) {
         $group = Group::findOrFail(Input::get('group_id'));
         $member->group()->associate($group);
     }
     //$member->photo = Input::get('photo');
     //$member->signature = Input::get('signature');
     if (Input::hasFile('photo')) {
         $destination = public_path() . '/uploads/photos';
         $filename = str_random(12);
         $ext = Input::file('photo')->getClientOriginalExtension();
         $photo = $filename . '.' . $ext;
         Input::file('photo')->move($destination, $photo);
         $member->photo = $photo;
     }
     if (Input::hasFile('signature')) {
         $destination = public_path() . '/uploads/photos';
         $filename = str_random(12);
         $ext = Input::file('signature')->getClientOriginalExtension();
         $photo = $filename . '.' . $ext;
         Input::file('signature')->move($destination, $photo);
         $member->signature = $photo;
     }
     $member->name = Input::get('name');
     $member->id_number = Input::get('id_number');
     $member->membership_no = Input::get('membership_no');
     $member->phone = Input::get('phone');
     $member->email = Input::get('email');
     $member->address = Input::get('address');
     $member->monthly_remittance_amount = Input::get('monthly_remittance_amount');
     $member->gender = Input::get('gender');
     $member->update();
     return Redirect::route('members.index');
 }
Example #11
0
 /**
  * Display the specified resource.
  *
  * @param  int  $groupId
  * @param  int  $id
  * @return Response
  */
 public function show($groupId, $id)
 {
     $score = Group::findOrFail($groupId)->scores()->findOrFail($id);
     return response()->json($score);
 }