예제 #1
0
 /**
  * Creates a new project using the input from the form
  *
  * @param CreateProjectRequest $request The validated request
  * @return mixed
  */
 public function create(CreateProjectRequest $request)
 {
     $newEntry = Project::create(['author' => Auth::user()->username, 'user_id' => Auth::user()->id, 'title' => $request->getTitle(), 'description' => $request->getDescription(), 'body' => $request->getBody(), 'statement_title' => 'Mission Statement', 'statement_body' => 'This is where you write about your mission statement or make it whatever you want.', 'tab_title' => 'Welcome', 'tab_body' => 'Here you can write a message or maybe the status of your project for all your members to see.']);
     $thumbnail = $request->file('thumbnail');
     $thumbnail->move(base_path() . '/public/images/projects', 'product' . $newEntry->id . '.jpg');
     //Sets banner image to a random pre-made banner
     $images = glob(base_path() . "/public/images/banners/*");
     $imagePath = base_path() . '/public/images/projects/' . 'banner' . $newEntry->id . '.jpg';
     $rand = random_int(0, count($images) - 1);
     \File::copy($images[$rand], $imagePath);
     //Add creator as a member and make admin of the project
     $newEntry->addMember(true);
     //Add creator as a follower of the project
     $newEntry->addFollower();
     return redirect('/project/' . $newEntry->title);
 }