app/Http/Controllers/BranchController.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)
    {
        $input = $request->all();
		$rules = array ('name' => 'required',
						'type' => 'required',
						'telephone' => 'required|numeric',
						'address' => 'required',);
		$message = ['name.required' => 'Please input the branch name',
					'type.required' => 'Please input the branch type',
					'telephone.required' => 'Please input the telephone number',
					'telephone.numeric' => 'Please input the telephone number in correct format',
					'address.required' => 'Please input the address',];
		$validator = Validator::make($input, $rules, $message);
		if($validator->fails()) {
			return Redirect::to('branch/create')->withErrors($validator);
		}else {
			$branch = new Branch;
			$branch->name = $request->name;
			$branch->type = $request->type;
			$branch->telephone = $request->telephone;
			$branch->address = $request->address;
			$branch->save();
			return back()->with('Apply Branch Information','Apply Branch Information Sucessfully!');
		}
    }
public function store ( Request $ request ) { $ input = $ request -> all ( ) ; $ rules = array ( 'name' => 'required' , 'type' => 'required' , 'telephone' => 'required|numeric' , 'address' => 'required' , ) ; $ message = [ 'name.required' => 'Please input the branch name' , 'type.required' => 'Please input the branch type' , 'telephone.required' => 'Please input the telephone number' , 'telephone.numeric' => 'Please input the telephone number in correct format' , 'address.required' => 'Please input the address' , ] ; $ validator = Validator :: make ( $ input , $ rules , $ message ) ; if ( $ validator -> fails ( ) ) { return Redirect :: to ( 'branch/create' ) -> withErrors ( $ validator ) ; } else { $ branch = new Branch ; $ branch -> name = $ request -> name ; $ branch -> type = $ request -> type ; $ branch -> telephone = $ request -> telephone ; $ branch -> address = $ request -> address ; $ branch -> save ( ) ; return back ( ) -> with ( 'Apply Branch Information' , 'Apply Branch Information Sucessfully!' ) ; } }
Store a newly created resource in storage.
Store a newly created resource in storage .