Example #1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function postCreate()
 {
     /*
     		Validator::make(
     array(
     	'title' => Input::get('title'),
     	'description' => Input::get('description'),
     	'content' => Input::get('content'),
     	'program' => Input::get('program'),
     	'address' => Input::get('address'),
     	'company_id' => Input::get('company_id'),
     	'event_id' => Input::get('event_id'),
     	'category_id' => Input::get('category_id'),
     	'start' => date("Y-m-d", Input::get('start')),
     	'end' => date("Y-m-d", Input::get('end'))
     	),
     array(
     	'title' => 'required',
     	'description' => 'required',
     	'content' => 'required',
     	'program' => 'required',
     	'address' => 'required',
     	'company_id' => 'required|integer',
     	'event_id' => 'required|integer',
     	'category_id' => 'required|integer',
     	'start' => 'required|date',
     	'end' => 'required|date',
     	)
     );
     */
     $header = Input::file('header');
     $image = Input::file('image');
     $validator = Validator::make(array('header' => $header, 'image' => $image), array('header' => 'mimes:png,jpeg,gif', 'image' => 'mimes:png,jpeg,gif'), array('mimes' => 'Tipo de imagen inválido, solo se admite los formatos PNG, JPEG, y GIF'));
     if ($validator->fails()) {
         return Redirect::to($this->route . '/create')->with('msg_succes', Lang::get('messages.companies_create_img_err'));
     } else {
         if ($header != "") {
             $headerfilename = $this->uploadHeader($header);
         } else {
             $headerfilename = "";
         }
         if ($image != "") {
             $imagefilename = $this->uploadCourseImage($image);
         } else {
             $imagefilename = "";
         }
         $course = new Courses();
         $course->title = Input::get('title');
         $course->description = Input::get('description');
         $course->header = $headerfilename;
         $course->image = $imagefilename;
         /*
         $course->description = Input::get('description');
         $course->inscription = Input::get('inscription');
         $course->associates_payment = Input::get('associates_payment');
         $course->participants_payment = Input::get('participants_payment');
         $course->associates_message = Input::get('associates_message');
         $course->program = Input::get('program');
         $course->participants_message = Input::get('participants_message');
         */
         $course->category_id = Input::get('category_id');
         $course->company_id = Input::get('company_id');
         $course->event_id = Input::get('event_id');
         $course->type = Input::get('type');
         $course->route = Input::get('route');
         $course->min = Input::get('min');
         $course->max = Input::get('max');
         $course->min_message = Input::get('min_message');
         $course->max_message = Input::get('max_message');
         $course->address = Input::get('address');
         $course->start = date("Y-m-d", strtotime(Input::get('start')));
         $course->end = date("Y-m-d", strtotime(Input::get('end')));
         if ($course->save()) {
             /*$teachers = Input::get('teachers');
             		$course->teachers()->sync($teachers);
             		$promotioners = Input::get('promotioners');
             		$course->promotioners()->sync($promotioners);
             		$supporters = Input::get('supporters');
             		$course->supporters()->sync($supporters);*/
             $sections = Input::get('section');
             $course->sections()->sync($sections);
             return Redirect::to($this->route)->with('msg_success', Lang::get('messages.companies_create', array('title' => $course->title)));
         } else {
             return Redirect::to($this->route)->with('msg_error', Lang::get('messages.companies_create_err', array('title' => $course->title)));
         }
     }
 }