/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $data = Model::create($request->all());
     return redirect()->route('routename')->with('status', 'Successfully Created');
 }
 /**
  * Override the default ::create method to automatically assign some attributes.
  * This also automatically sets up the role and sends the new user an email.
  * @param array $attributes
  * @param bool  $sendEmail
  * @return static
  */
 public static function create(array $attributes = [], $sendEmail = true)
 {
     // Set up the default parameters
     if (!isset($attributes['email']) && isset($attributes['username'])) {
         $attributes['email'] = $attributes['username'] . '@bath.ac.uk';
     }
     if (!isset($attributes['password'])) {
         $password = str_random(15);
         $attributes['password'] = bcrypt($password);
     }
     if (!isset($attributes['status'])) {
         $attributes['status'] = true;
     }
     if (isset($attributes['type'])) {
         $type = $attributes['type'];
         unset($attributes['type']);
     }
     // Create the user
     $user = parent::create($attributes);
     if (isset($type)) {
         $user->type = $type;
     }
     if ($user && $sendEmail && isset($password)) {
         // Send an email to the new user
         Mail::queue('emails.users.create', ['name' => $user->forename, 'password' => $password], function ($message) use($user) {
             $message->subject('Your new Backstage account')->to($user->email, $user->name);
         });
     }
     return $user;
 }