/**
  * User stars/un-stars a project (POST)
  *
  * @param Project $project
  * @return array JSON response
  */
 public function postStar(Project $project)
 {
     $response = array();
     $response['project'] = $project->toArray();
     if (!in_array(Auth::user()->id, $project->users()->lists('id')->toArray())) {
         Auth::user()->projects()->attach($project->id);
         $response['message'] = "成功收藏&nbsp;<span>" . $project->title . "</span>";
     } else {
         Auth::user()->projects()->detach($project->id);
         $response['message'] = "已取消收藏&nbsp;<span>" . $project->title . "</span>";
     }
     return $response;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param Project $project
  * @internal param int $id
  * @return Response
  */
 public function destroy(Project $project)
 {
     if ($project->todos) {
         foreach ($project->todos as $todos) {
             if (!$todos->completed) {
                 Flash::error('This project has incomplete todos.  Mark them as completed or remove them.');
                 return redirect()->route('projects.todos.index', [$project->id]);
             }
         }
     }
     $project_array = $project->toArray();
     $emails = $project->subscribers()->lists('email');
     Mail::send('projects.emails.delete', ['name' => $project->name, 'user' => $project->user->name], function ($message) use($emails, $project_array) {
         $message->from('*****@*****.**');
         $message->to($emails)->subject("USC Todo App - The '{$project_array['name']}' project has been removed!");
     });
     $project->delete();
     Flash::success('The project has been deleted!');
     return redirect()->route('projects.index');
 }