/**
  * Store a newly created resource in storage.
  *
  * @param CreateGroupRequest $request
  * @return Response
  */
 public function store(CreateGroupRequest $request)
 {
     $input = $request->all();
     $group = new Group();
     $group->name = $input['name'];
     $group->founderId = Auth::id();
     \DB::insert('INSERT INTO conversations VALUE ()');
     $conversationId = \DB::select('SELECT id FROM conversations ORDER BY id DESC LIMIT 1')[0]->id;
     $group->conversationId = $conversationId;
     $group->private = $request->type == "private" ? true : false;
     storeGroup($group);
     $mygroup = loadGroup($group->name)[0];
     addMemberToGroup($mygroup->founderId, $mygroup->id);
     return redirect('groups/' . $mygroup->id);
 }
예제 #2
0
 public function store(CreateGroupRequest $request)
 {
     if (Gate::denies('managerOnly')) {
         abort(403);
     }
     $input = $request->all();
     $result = DB::transaction(function ($input) use($input) {
         $group = new Group();
         $group->name = $input['name'];
         $group->organization()->associate(Auth::user()->organization);
         $group->save();
         foreach ($input['users'] as $user) {
             $group->users()->attach($user['id']);
         }
         foreach ($input['indicators'] as $indicator) {
             $group->indicators()->attach($indicator['id']);
         }
         return $group;
     });
     return $result;
 }
예제 #3
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(CreateGroupRequest $request, Group $group)
 {
     $group->updated_at = Carbon::now();
     $group->update($request->all());
     Session::flash('flash_message', $group->linkedName() . ' has been updated');
     return redirect('/admin/group');
 }
예제 #4
0
 public function store(CreateGroupRequest $request)
 {
     $groupType = Group::create($request->all());
     return redirect()->route('groups.index')->with('successes', ['Group created successfully']);
 }