m3 Security Fixes
This commit is contained in:
@@ -2,14 +2,11 @@
|
||||
|
||||
namespace Modules\M3\Http\Controllers;
|
||||
|
||||
use Modules\M3\Models\ShipTo;
|
||||
|
||||
use Modules\M3\Http\Controllers\Controller;
|
||||
use DB;
|
||||
use Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Datatables;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\M3\Helpers\CAProvinces;
|
||||
use Modules\M3\Helpers\USStates;
|
||||
use Modules\M3\Models\ShipTo;
|
||||
|
||||
class ShipToController extends Controller
|
||||
{
|
||||
@@ -28,22 +25,24 @@ class ShipToController extends Controller
|
||||
$actionBtn .= '<form method="POST" action="' . url('ship-to/' . urlencode(trim($row->AUSHSHZP)) . '/' . urlencode(trim($row->AUSHWHS))) . '" style="display:inline">';
|
||||
$actionBtn .= csrf_field() . method_field('DELETE');
|
||||
$actionBtn .= '<button type="submit" class="btn btn-danger btn-sm" onclick="return confirm(\'Are you sure?\')">Delete</button></form>';
|
||||
|
||||
return $actionBtn;
|
||||
})
|
||||
->rawColumns(['checkbox', 'action'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
return view('m3::liberty-theme.pages.ship-to.index');
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
# US
|
||||
$USstates = \Modules\M3\Helpers\USStates::all();
|
||||
# CA
|
||||
$CAstates = \Modules\M3\Helpers\CAProvinces::all();
|
||||
// US
|
||||
$USstates = USStates::all();
|
||||
// CA
|
||||
$CAstates = CAProvinces::all();
|
||||
|
||||
# All States
|
||||
// All States
|
||||
$states = array_merge($USstates, $CAstates);
|
||||
|
||||
return view('m3::liberty-theme.pages.ship-to.create', compact('states'));
|
||||
@@ -53,7 +52,7 @@ class ShipToController extends Controller
|
||||
{
|
||||
$validated = $request->validate(
|
||||
[
|
||||
'AUSTCN' => 'nullable|max:11',
|
||||
'AUSTCN' => 'nullable|max:11',
|
||||
'AUSHSHNM' => 'required|max:36',
|
||||
'AUSHSHA1' => 'required|max:36',
|
||||
'AUSHSHA2' => 'required|max:36',
|
||||
@@ -63,7 +62,7 @@ class ShipToController extends Controller
|
||||
'AUSHSHST' => 'required|max:2',
|
||||
'AUSHSHZP' => 'required|max:10',
|
||||
'AUSHSHCT' => 'required|max:3',
|
||||
'AUSHWHS' => 'required|max:3'
|
||||
'AUSHWHS' => 'required|max:3',
|
||||
],
|
||||
[
|
||||
'AUSHSHNM.required' => 'Name is required',
|
||||
@@ -73,9 +72,9 @@ class ShipToController extends Controller
|
||||
'AUSHSHST.required' => 'State is required',
|
||||
'AUSHSHZP.required' => 'Zip code is required',
|
||||
'AUSHSHCT.required' => 'Country is required',
|
||||
'AUSHWHS.required' => 'Warehouse is required',
|
||||
'AUSHWHS.required' => 'Warehouse is required',
|
||||
|
||||
'AUSTCN.max' => 'Customer Number cannot exceed 11 characters',
|
||||
'AUSTCN.max' => 'Customer Number cannot exceed 11 characters',
|
||||
'AUSHSHNM.max' => 'Name cannot exceed 36 characters',
|
||||
'AUSHSHA1.max' => 'Address 1 cannot exceed 36 characters',
|
||||
'AUSHSHA2.max' => 'Address 2 cannot exceed 36 characters',
|
||||
@@ -85,12 +84,12 @@ class ShipToController extends Controller
|
||||
'AUSHSHST.max' => 'State cannot exceed 2 characters',
|
||||
'AUSHSHZP.max' => 'Zip code cannot exceed 10 characters',
|
||||
'AUSHSHCT.max' => 'Country cannot exceed 3 characters',
|
||||
'AUSHWHS.max' => 'Warehouse cannot exceed 3 characters'
|
||||
]
|
||||
'AUSHWHS.max' => 'Warehouse cannot exceed 3 characters',
|
||||
],
|
||||
);
|
||||
$validated['AUSTCN'] = $validated['AUSTCN'] ?? ' ';
|
||||
|
||||
$model = new ShipTo();
|
||||
$model = new ShipTo;
|
||||
$model->fill($validated);
|
||||
$success = $model->save();
|
||||
// ShipTo::create($validated);
|
||||
@@ -105,17 +104,18 @@ class ShipToController extends Controller
|
||||
|
||||
public function edit($aushshzp, $aushwhs)
|
||||
{
|
||||
# US
|
||||
$USstates = \Modules\M3\Helpers\USStates::all();
|
||||
# CA
|
||||
$CAstates = \Modules\M3\Helpers\CAProvinces::all();
|
||||
// US
|
||||
$USstates = USStates::all();
|
||||
// CA
|
||||
$CAstates = CAProvinces::all();
|
||||
|
||||
# All States
|
||||
// All States
|
||||
$states = array_merge($USstates, $CAstates);
|
||||
|
||||
$shipTo = ShipTo::where('AUSHSHZP', $aushshzp)
|
||||
->where('AUSHWHS', $aushwhs)
|
||||
->firstOrFail();
|
||||
|
||||
return view('m3::liberty-theme.pages.ship-to.edit', compact('shipTo', 'states'));
|
||||
}
|
||||
|
||||
@@ -124,40 +124,40 @@ class ShipToController extends Controller
|
||||
$validated = array_map(function ($value) {
|
||||
return $value === null ? '' : $value;
|
||||
}, $request->validate(
|
||||
[
|
||||
'AUSTCN' => 'nullable|string|max:11',
|
||||
'AUSHSHNM' => 'required|max:36',
|
||||
'AUSHSHA1' => 'required|max:36',
|
||||
'AUSHSHA2' => 'required|max:36',
|
||||
'AUSHSHA3' => 'nullable|string|max:36',
|
||||
'AUSHSHA4' => 'nullable|string|max:36',
|
||||
'AUSHSHCI' => 'required|max:20',
|
||||
'AUSHSHST' => 'required|max:2',
|
||||
'AUSHSHCT' => 'required|max:3'
|
||||
],
|
||||
[
|
||||
'AUSHSHNM.required' => 'Name is required',
|
||||
'AUSHSHA1.required' => 'Address 1 is required',
|
||||
'AUSHSHA2.required' => 'Address 2 is required',
|
||||
'AUSHSHCI.required' => 'City is required',
|
||||
'AUSHSHST.required' => 'State is required',
|
||||
'AUSHSHZP.required' => 'Zip code is required',
|
||||
'AUSHSHCT.required' => 'Country is required',
|
||||
'AUSHWHS.required' => 'Warehouse is required',
|
||||
[
|
||||
'AUSTCN' => 'nullable|string|max:11',
|
||||
'AUSHSHNM' => 'required|max:36',
|
||||
'AUSHSHA1' => 'required|max:36',
|
||||
'AUSHSHA2' => 'required|max:36',
|
||||
'AUSHSHA3' => 'nullable|string|max:36',
|
||||
'AUSHSHA4' => 'nullable|string|max:36',
|
||||
'AUSHSHCI' => 'required|max:20',
|
||||
'AUSHSHST' => 'required|max:2',
|
||||
'AUSHSHCT' => 'required|max:3',
|
||||
],
|
||||
[
|
||||
'AUSHSHNM.required' => 'Name is required',
|
||||
'AUSHSHA1.required' => 'Address 1 is required',
|
||||
'AUSHSHA2.required' => 'Address 2 is required',
|
||||
'AUSHSHCI.required' => 'City is required',
|
||||
'AUSHSHST.required' => 'State is required',
|
||||
'AUSHSHZP.required' => 'Zip code is required',
|
||||
'AUSHSHCT.required' => 'Country is required',
|
||||
'AUSHWHS.required' => 'Warehouse is required',
|
||||
|
||||
'AUSTCN.max' => 'Customer Number cannot exceed 11 characters',
|
||||
'AUSHSHNM.max' => 'Name cannot exceed 36 characters',
|
||||
'AUSHSHA1.max' => 'Address 1 cannot exceed 36 characters',
|
||||
'AUSHSHA2.max' => 'Address 2 cannot exceed 36 characters',
|
||||
'AUSHSHA3.max' => 'Address 3 cannot exceed 36 characters',
|
||||
'AUSHSHA4.max' => 'Address 4 cannot exceed 36 characters',
|
||||
'AUSHSHCI.max' => 'City cannot exceed 20 characters',
|
||||
'AUSHSHST.max' => 'State cannot exceed 2 characters',
|
||||
'AUSHSHZP.max' => 'Zip code cannot exceed 10 characters',
|
||||
'AUSHSHCT.max' => 'Country cannot exceed 3 characters',
|
||||
'AUSHWHS.max' => 'Warehouse cannot exceed 3 characters'
|
||||
]
|
||||
));
|
||||
'AUSTCN.max' => 'Customer Number cannot exceed 11 characters',
|
||||
'AUSHSHNM.max' => 'Name cannot exceed 36 characters',
|
||||
'AUSHSHA1.max' => 'Address 1 cannot exceed 36 characters',
|
||||
'AUSHSHA2.max' => 'Address 2 cannot exceed 36 characters',
|
||||
'AUSHSHA3.max' => 'Address 3 cannot exceed 36 characters',
|
||||
'AUSHSHA4.max' => 'Address 4 cannot exceed 36 characters',
|
||||
'AUSHSHCI.max' => 'City cannot exceed 20 characters',
|
||||
'AUSHSHST.max' => 'State cannot exceed 2 characters',
|
||||
'AUSHSHZP.max' => 'Zip code cannot exceed 10 characters',
|
||||
'AUSHSHCT.max' => 'Country cannot exceed 3 characters',
|
||||
'AUSHWHS.max' => 'Warehouse cannot exceed 3 characters',
|
||||
],
|
||||
));
|
||||
|
||||
$updated = ShipTo::where('AUSHSHZP', $aushshzp)
|
||||
->where('AUSHWHS', $aushwhs)
|
||||
@@ -183,5 +183,4 @@ class ShipToController extends Controller
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user