Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function page()
 {
     $comment = new Comment();
     $comment->nickname = Input::get('nickname');
     $comment->email = Input::get('email');
     $comment->website = Input::get('website');
     $comment->content = Input::get('content');
     $comment->page_id = Input::get('page_id');
     if ($comment->save()) {
         return Redirect::back();
     } else {
         return Redirect::back()->withInput() - withErrors('评论发表失败!');
     }
 }
Exemplo n.º 2
0
 public function postCreate()
 {
     $validator = Validator::make(Input::all(), array('email' => 'required|max:50|email|unique:users', 'username' => 'required|max:20|min:3|unique:users', 'password' => 'required|min:6', 'password_again' => 'required|same:password'));
     if ($validator->fails()) {
         return Redirect::route('create') > withErrors($validator)->withInput();
     } else {
         //create user account
         $user = User::create(array('email' => Input::get('email'), 'username' => Input::get('username'), 'password' => Hash::make(Input::get('password')), 'code' => str_random(60), 'active' => 1));
         //normally active = 0 but until we can get email validation working it will stay 1);
         $user->save();
         $user->sex = Input::get('sex');
         $user->birth_month = Input::get('birth_month');
         $user->birth_day = Input::get('birth_day');
         $user->birth_year = Input::get('birth_year');
         $user->party = Input::get('party');
         $user->bio = Input::get('bio');
         //Upload Image
         $file = Input::file('photo');
         if (isset($file)) {
             if ($file->isValid()) {
                 $destinationPath = public_path() . '/assets/images/avatars/';
                 // The destination were you store the image.
                 $filename = $file->getClientOriginalName();
                 $file->move($destinationPath, $filename);
                 $user->pic_url = '/assets/images/avatars/' . $filename;
             }
         }
         $user->save();
         /* $filename           = $file->getClientOriginalName(); // Original file name that the end user used for it.
          			 $mime_type          = $file->getMimeType(); // Gets this example image/png
         			 $extension          = $file->getClientOriginalExtension(); // The original extension that the user used example .jpg or .png.
          			try{ $upload_success     = $file->move($destinationPath, $filename); // Now we move the file to its new home.
         			} catch (Exception $e) {return 'Caught exception image upload: '.$e->getMessage();}
                                */
         // This is were you would store the image path in a table
         $issues = Issue::all();
         foreach ($issues as $issue) {
             $issue_checkbox = Input::get($issue->id);
             if (isset($issue_checkbox)) {
                 $issues_follows = IssueFollow::create(array('issue_id' => $issue_checkbox, 'user_id' => $user->id));
                 $issues_follows->save();
             }
         }
         //Redirect to login page - added to redirect to home upon successful account
         $auth = Auth::attempt(array('email' => Input::get('email'), 'password' => Input::get('password'), 'active' => 1));
         return Redirect::route('myprofile');
     }
     // else
     /*
     	if ($user){
             
     	//send email here
     		Mail::send(/*'emails.activate',*/
     /*'activate',
     		array('link' =>URL::route('activate',$code), 'username'=>$username),function($message) use ($user){
     	       return $message->to($user->email,$user->username)->subject('Activate your account');
     		});
     			
     				return Redirect::route('home')
     				->with('global','Your account has been created! We have sent you an email to activate your account');
     			
     		  
                }*/
     //if ($user)
 }
Exemplo n.º 3
0
 public function store()
 {
     if (Request::ajax()) {
         $inputData = Request::get('form#createProject');
         parse_str($inputData, $formFields);
         $projectData = array('code' => $formFields['projectCode'], 'name' => $formFields['projectName'], 'version' => $formFields['projectVersion'], 'startDate' => $formFields['projectStartDate'], 'endDate' => $formFields['projectEndDate']);
         $rules = array('code' => 'required|min:3|alpha_num', 'name' => 'required|min:3', 'version' => 'required|min:1', 'startDate' => 'required|date', 'endDate' => 'required|date');
         $validator = Validator::make($projectData, $rules);
         if ($validator->fails()) {
             return Response::json(array('fail' => true, 'errors' => withErrors($validator)));
         } else {
             Projects::create($projectData);
             $response = array('status' => 'success', 'msg' => 'Setting created successfully');
             return Response::json($response);
         }
     }
 }