public function __construct()
 {
     $this->middleware('auth');
     $user_types = UserType::lists("name", "id");
     $states = State::lists("name", "id");
     $users_count = User::with("state")->latest()->get()->count();
     $universities_count = University::latest()->get()->count();
     $sos_count = SosModel::latest()->get()->count();
     $students_count = Student::latest()->get()->count();
     $companies_count = Company::latest()->get()->count();
     \View::share(compact("users_count", "universities_count", "sos_count", "states", "user_types", "students_count", "companies_count"));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(SosModelRequest $request)
 {
     $data = $request->all();
     $user = User::findOrFail($request->input('user_id'));
     $sos = SosModel::create(['name' => date("ymdh"), 'user_id' => $request->input('user_id')]);
     $sos->companies()->attach($data["company_id"]);
     foreach ($data["company_id"] as $key => $company) {
         $company = Company::findOrFail($company);
         \Mail::send('emails.letter', compact('user', 'company'), function ($message) use($company, $user) {
             $message->to($company->email, env('MAIL_FROM_NAME'))->subject('Internship Letter');
         });
     }
     return redirect("/sos-requests");
 }