/**
  * Process a post request, creating a new user
  *
  * Note: we don't just create using the raw request data because the password
  * needs to be encrypted
  */
 public function store(Request $request)
 {
     $data = $request->all();
     User::create(['name' => $data['name'], 'username' => $data['username'], 'role' => $data['role'], 'email' => $data['email'], 'phone' => $data['phone'], 'color' => $data['color'], 'password' => bcrypt($data['password'])]);
     // after we create the user, go to the directory
     return redirect('directory');
 }
 /**
  * Given an array of shifts, return xml formatted the way the monthly.js plugin
  * needs it
  *
  * @var array $shifts
  * @return formatetd xml
  *
  * @todo this bit of business logic really probably ought to go elsewhere, but
  * I don't understand laravel 5 well enough yet to know exactly where
  */
 protected function getScheduleXml($shifts)
 {
     $scheduleXml = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><monthly/>');
     foreach ($shifts as $shift) {
         // get the employee who is scheduled for this shift
         $employee = User::find($shift->employee_id);
         $name = $employee ? $employee->name : "Open shift";
         $color = $employee ? $employee->color : "grey";
         $url = $employee ? "/contact/" . $employee->id : "";
         $shiftXml = $scheduleXml->addChild('event');
         $shiftXml->addChild('id', $shift->id);
         $shiftXml->addChild('name', $name);
         $shiftXml->addChild('startdate', $shift->start_time->format("Y-m-d"));
         $shiftXml->addChild('enddate', $shift->end_time->format("Y-m-d"));
         $shiftXml->addChild('starttime', $shift->start_time->format("H:i"));
         $shiftXml->addChild('endtime', $shift->end_time->format("H:i"));
         $shiftXml->addChild('color', $color);
         $shiftXml->addChild('url', $url);
     }
     return $scheduleXml->asXML();
 }
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     return User::create(['name' => $data['name'], 'username' => $data['username'], 'role' => $data['role'], 'email' => $data['email'], 'phone' => $data['phone'], 'color' => $data['color'], 'password' => bcrypt($data['password'])]);
 }