public function store(Request $request)
 {
     if (!$request->user()->hasRole('admin')) {
         return abort(403, 'You do not have permission to perform that action');
     }
     $this->validateTeamMemberFormInput($request);
     TeamMember::create($request->only(['name', 'title', 'intro']));
     $this->flasher->success('Team Member Added', 'Growth is the most vital sign of life!');
     return redirect('admin/team');
 }
Exemple #2
0
 public function addMember(Request $request)
 {
     $id = $request->get('id');
     $users = $request->get('users');
     foreach ($users as $user) {
         $member = TeamMember::where(['team_id' => $id, 'user_id' => $user])->get();
         if (count($member) == 0) {
             $r1 = TeamMember::create(array('team_id' => $id, 'user_id' => $user, 'role' => 2));
             $r2 = $this->createTeamTrace($id, '添加成员', $this->getUserNameById($user));
         }
     }
     if ($r1 && $r2) {
         $this->succeed(true);
     } else {
         $this->fail(true);
     }
 }