app/Http/Controllers/RequirementController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $create_new_validator = $this->create_new_validator($request->all());
        if ($create_new_validator->fails()) {
            $this->throwValidationException(
                $request, $create_new_validator
                );
        } else {
            $user = \Auth::user();
            $requirement                = new Requirement;
            $requirement->created_by    = $user->id;
            $requirement->subject_id    = $request->input('subject');
            $requirement->priority_id   = $request->input('priority');
            $requirement->description   = $request->input('description');
            if(Input::file('upload') != NULL && $requirement->save()){
                $upload             = Input::file('upload');
                $filename           = 'requirementFile.' . $upload->getClientOriginalExtension();
                $save_path          = '/users/id/' . $user->id . '/uploads/requirements/'.$requirement->id;
                $upload->move(storage_path().$save_path, $filename);
                $requirement->archive = '/files/users/' . $user->id . '/requirements/'. $requirement->id . '/' . $filename;
                $requirement->file_ext = $upload->getClientOriginalExtension();
            }
            $requirement->save();
            return redirect('requirement')->with('status', 'Ticket de Requerimiento creado éxitosamente!');
        }
    }
public function store ( Request $ request ) { $ create_new_validator = $ this -> create_new_validator ( $ request -> all ( ) ) ; if ( $ create_new_validator -> fails ( ) ) { $ this -> throwValidationException ( $ request , $ create_new_validator ) ; } else { $ user = \ Auth :: user ( ) ; $ requirement = new Requirement ; $ requirement -> created_by = $ user -> id ; $ requirement -> subject_id = $ request -> input ( 'subject' ) ; $ requirement -> priority_id = $ request -> input ( 'priority' ) ; $ requirement -> description = $ request -> input ( 'description' ) ; if ( Input :: file ( 'upload' ) != NULL && $ requirement -> save ( ) ) { $ upload = Input :: file ( 'upload' ) ; $ filename = 'requirementFile.' . $ upload -> getClientOriginalExtension ( ) ; $ save_path = '/users/id/' . $ user -> id . '/uploads/requirements/' . $ requirement -> id ; $ upload -> move ( storage_path ( ) . $ save_path , $ filename ) ; $ requirement -> archive = '/files/users/' . $ user -> id . '/requirements/' . $ requirement -> id . '/' . $ filename ; $ requirement -> file_ext = $ upload -> getClientOriginalExtension ( ) ; } $ requirement -> save ( ) ; return redirect ( 'requirement' ) -> with ( 'status' , 'Ticket de Requerimiento creado éxitosamente!') ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .
// MAKE USER FOLDER AND UPDATE PERMISSIONS // File::makeDirectory($save_path, $mode = 0755, true, true); // SAVE FILE TO SERVER // SAVE ROUTED PATH TO FILE TO DATABASE