Example #1
0
 /**
  * Create a new project
  *
  * @param  array  $input
  * @return array
  */
 public static function create_project($input, $image)
 {
     $rules = array('name' => 'required|max:250');
     $validator = \Validator::make($input, $rules);
     if ($validator->fails()) {
         return array('success' => false, 'errors' => $validator->errors);
     }
     $fill = array('name' => $input['name'], 'image' => $image);
     $project = new Project();
     $project->fill($fill);
     $project->save();
     /* Assign selected users to the project */
     if (isset($input['user']) && count($input['user']) > 0) {
         foreach ($input['user'] as $id) {
             $project->assign_user($id);
         }
     }
     return array('project' => $project, 'success' => true);
 }