What I tried so far ?
My Request class is below
class SubCategoryRequest extends Request
{
public function authorize()
{
if(\Auth::user()->RoleID == \App\Enumeration\Role\RoleType::Admin) {
return true;
}
return false;
}
public function rules()
{
$rules = [];
$rules['SubCategory'] = 'required|max:25|min:5|unique:tblsubcategory,CategoryID';
$rules['CategoryID'] = 'required';
return $rules;
}
public function response(array $errors){
return \Redirect::back()->withErrors($errors)->withInput();
}
}
Below is the Database Table Schema
CREATE TABLE `tblsubcategory` (
`SubCategoryID` int(11) NOT NULL,
`SubCategory` varchar(25) NOT NULL,
`CategoryID` int(11) NOT NULL,
`IsActive` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `tblsubcategory`
MODIFY `SubCategoryID` int(11) NOT NULL AUTO_INCREMENT;
Below is Unique Key Constraint
ALTER TABLE `tblsubcategory`
ADD PRIMARY KEY (`SubCategoryID`),
ADD UNIQUE KEY `UK_tblSubCategory_SubCategory_CategoryID` (`CategoryID`,`SubCategory`);
Question
Am I missing something ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire