Commit 5046b78a by Pancholin

validaciones de requests

parent 48faee1a
......@@ -11,6 +11,9 @@ use Onestartup\Product\Model\ProductImage as Gallery;
use Onestartup\Product\Model\Product;
use Onestartup\Product\Model\Variable as Variable;
use Onestartup\Product\Requests\RequestProduct;
use Onestartup\Product\Requests\RequestVariables;
class AdminProductController extends Controller
{
public function index()
......@@ -37,7 +40,7 @@ class AdminProductController extends Controller
* @param Request $request
* @return Response
*/
public function store(Request $request)
public function store(RequestProduct $request)
{
$product = new Product($request->all());
......@@ -82,7 +85,7 @@ class AdminProductController extends Controller
* @param Request $request
* @return Response
*/
public function update(Request $request, $id)
public function update(RequestProduct $request, $id)
{
$product = Product::find($id);
$product->fill($request->all());
......@@ -230,7 +233,7 @@ class AdminProductController extends Controller
->with('variable', $variable);
}
public function postVars(Request $request)
public function postVars(RequestVariables $request)
{
$variable = Variable::first();
......
......@@ -9,6 +9,8 @@ use Yajra\Datatables\Datatables;
use Onestartup\Product\Model\ProductCategory as Category;
use Onestartup\Product\Requests\RequestCreateCategory;
use Onestartup\Product\Requests\RequestEditCategory;
class CategoryController extends Controller
{
/**
......@@ -28,7 +30,7 @@ class CategoryController extends Controller
* @param Request $request
* @return Response
*/
public function store(Request $request)
public function store(RequestCreateCategory $request)
{
$category = new Category($request->all());
......@@ -67,7 +69,7 @@ class CategoryController extends Controller
* @param Request $request
* @return Response
*/
public function update(Request $request, $id)
public function update(RequestEditCategory $request, $id)
{
$category = Category::find($id);
$category->fill($request->all());
......
<?php
namespace Onestartup\Product\Requests;
use Illuminate\Foundation\Http\FormRequest;
class RequestCreateCategory extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required|max:355',
'slug' => 'required|max:255',
'description'=> 'max:455',
'active' => 'required'
];
}
}
\ No newline at end of file
<?php
namespace Onestartup\Product\Requests;
use Illuminate\Foundation\Http\FormRequest;
class RequestEditCategory extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required|max:355',
'slug' => 'required|max:255',
'description'=> 'max:455',
'active' => 'required'
];
}
}
\ No newline at end of file
<?php
namespace Onestartup\Product\Requests;
use Illuminate\Foundation\Http\FormRequest;
class RequestProduct extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required|max:355',
'slug' => 'required|max:455',
'description'=> 'required',
'specifications' => 'required',
'features' => 'required',
'active' => 'required|boolean',
'publication_date' => 'required',
'extra1' => 'max:455',
'extra2' => 'max:455',
'extra3' => 'max:455',
'extra4' => 'max:455',
'extra5' => 'max:455',
'extra6' => 'max:455',
'extra7' => 'max:455',
'extra8' => 'max:455',
'extra9' => 'max:455',
'extra10' => 'max:455',
'category_id' => 'required|numeric'
];
}
}
\ No newline at end of file
<?php
namespace Onestartup\Product\Requests;
use Illuminate\Foundation\Http\FormRequest;
class RequestVariables extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'alias1' => 'max:455',
'alias2' => 'max:455',
'alias3' => 'max:455',
'alias4' => 'max:455',
'alias5' => 'max:455',
'alias6' => 'max:455',
'alias7' => 'max:455',
'alias8' => 'max:455',
'alias9' => 'max:455',
'alias10' => 'max:455',
'alias11' => 'max:455',
];
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment