4 changed files with 126 additions and 97 deletions
-
90app/Http/Controllers/Partners/CustomersController.php
-
57app/Http/Controllers/Partners/VendorsController.php
-
37app/Http/Requests/Partners/CustomerCreateRequest.php
-
39app/Http/Requests/Partners/CustomerUpdateRequest.php
@ -0,0 +1,37 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Http\Requests\Partners; |
||||
|
|
||||
|
use App\Entities\Partners\Customer; |
||||
|
use Illuminate\Foundation\Http\FormRequest; |
||||
|
|
||||
|
class CustomerCreateRequest extends FormRequest |
||||
|
{ |
||||
|
/** |
||||
|
* Determine if the user is authorized to make this request. |
||||
|
* |
||||
|
* @return bool |
||||
|
*/ |
||||
|
public function authorize() |
||||
|
{ |
||||
|
return $this->user()->can('create', new Customer); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Get the validation rules that apply to the request. |
||||
|
* |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function rules() |
||||
|
{ |
||||
|
return [ |
||||
|
'name' => 'required|max:60', |
||||
|
'email' => 'nullable|email|unique:customers,email', |
||||
|
'phone' => 'nullable|max:255', |
||||
|
'pic' => 'nullable|max:255', |
||||
|
'address' => 'nullable|max:255', |
||||
|
'website' => 'nullable|url|max:255', |
||||
|
'notes' => 'nullable|max:255', |
||||
|
]; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,39 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Http\Requests\Partners; |
||||
|
|
||||
|
use Illuminate\Foundation\Http\FormRequest; |
||||
|
|
||||
|
class CustomerUpdateRequest extends FormRequest |
||||
|
{ |
||||
|
/** |
||||
|
* Determine if the user is authorized to make this request. |
||||
|
* |
||||
|
* @return bool |
||||
|
*/ |
||||
|
public function authorize() |
||||
|
{ |
||||
|
return $this->user()->can('update', $this->route('customer')); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Get the validation rules that apply to the request. |
||||
|
* |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function rules() |
||||
|
{ |
||||
|
$customer = $this->route('customer'); |
||||
|
|
||||
|
return [ |
||||
|
'name' => 'required|max:60', |
||||
|
'email' => 'nullable|email|unique:customers,email,'.$customer->id, |
||||
|
'phone' => 'nullable|max:255', |
||||
|
'pic' => 'nullable|max:255', |
||||
|
'address' => 'nullable|max:255', |
||||
|
'website' => 'nullable|url|max:255', |
||||
|
'notes' => 'nullable|max:255', |
||||
|
'is_active' => 'required|boolean', |
||||
|
]; |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue