diff --git a/app/Http/Controllers/ProposalCategoryController.php b/app/Http/Controllers/ProposalCategoryController.php index 3a74d26a37..84236a0d9f 100644 --- a/app/Http/Controllers/ProposalCategoryController.php +++ b/app/Http/Controllers/ProposalCategoryController.php @@ -53,7 +53,7 @@ class ProposalCategoryController extends BaseController { $data = [ 'account' => auth()->user()->account, - 'proposalCategory' => null, + 'category' => null, 'method' => 'POST', 'url' => 'proposals/categories', 'title' => trans('texts.new_proposal_category'), @@ -71,7 +71,7 @@ class ProposalCategoryController extends BaseController $data = [ 'account' => auth()->user()->account, - 'proposalCategory' => $proposalCategory, + 'category' => $proposalCategory, 'method' => 'PUT', 'url' => 'proposals/categories/' . $proposalCategory->public_id, 'title' => trans('texts.edit_proposal_category'), diff --git a/app/Http/Requests/CreateProposalCategoryRequest.php b/app/Http/Requests/CreateProposalCategoryRequest.php new file mode 100644 index 0000000000..859a1cf1c0 --- /dev/null +++ b/app/Http/Requests/CreateProposalCategoryRequest.php @@ -0,0 +1,28 @@ +user()->can('create', ENTITY_PROPOSAL_CATEGORY); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + return [ + 'name' => 'required', + ]; + } +} diff --git a/app/Http/Requests/CreateProposalRequest.php b/app/Http/Requests/CreateProposalRequest.php new file mode 100644 index 0000000000..7b19f610eb --- /dev/null +++ b/app/Http/Requests/CreateProposalRequest.php @@ -0,0 +1,29 @@ +user()->can('create', ENTITY_PROPOSAL); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + return [ + 'quote_id' => 'required', + 'template_id' => 'required', + ]; + } +} diff --git a/app/Http/Requests/CreateProposalSnippetRequest.php b/app/Http/Requests/CreateProposalSnippetRequest.php new file mode 100644 index 0000000000..1ef6baeea4 --- /dev/null +++ b/app/Http/Requests/CreateProposalSnippetRequest.php @@ -0,0 +1,28 @@ +user()->can('create', ENTITY_PROPOSAL_SNIPPET); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + return [ + 'name' => 'required', + ]; + } +} diff --git a/app/Http/Requests/CreateProposalTemplateRequest.php b/app/Http/Requests/CreateProposalTemplateRequest.php new file mode 100644 index 0000000000..f3d37d7462 --- /dev/null +++ b/app/Http/Requests/CreateProposalTemplateRequest.php @@ -0,0 +1,28 @@ +user()->can('create', ENTITY_PROPOSAL_TEMPLATE); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + return [ + 'name' => 'required', + ]; + } +} diff --git a/app/Http/Requests/UpdateProposalCategoryRequest.php b/app/Http/Requests/UpdateProposalCategoryRequest.php new file mode 100644 index 0000000000..47b862592b --- /dev/null +++ b/app/Http/Requests/UpdateProposalCategoryRequest.php @@ -0,0 +1,32 @@ +entity() && $this->user()->can('edit', $this->entity()); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + if (! $this->entity()) { + return []; + } + + return [ + 'name' => 'required', + ]; + } +} diff --git a/app/Http/Requests/UpdateProposalRequest.php b/app/Http/Requests/UpdateProposalRequest.php new file mode 100644 index 0000000000..ea1801b8a4 --- /dev/null +++ b/app/Http/Requests/UpdateProposalRequest.php @@ -0,0 +1,33 @@ +entity() && $this->user()->can('edit', $this->entity()); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + if (! $this->entity()) { + return []; + } + + return [ + 'quote_id' => 'required', + 'template_id' => 'required', + ]; + } +} diff --git a/app/Http/Requests/UpdateProposalSnippetRequest.php b/app/Http/Requests/UpdateProposalSnippetRequest.php new file mode 100644 index 0000000000..a2d4bba9af --- /dev/null +++ b/app/Http/Requests/UpdateProposalSnippetRequest.php @@ -0,0 +1,32 @@ +entity() && $this->user()->can('edit', $this->entity()); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + if (! $this->entity()) { + return []; + } + + return [ + 'name' => 'required', + ]; + } +} diff --git a/app/Http/Requests/UpdateProposalTemplateRequest.php b/app/Http/Requests/UpdateProposalTemplateRequest.php new file mode 100644 index 0000000000..de4927a3ce --- /dev/null +++ b/app/Http/Requests/UpdateProposalTemplateRequest.php @@ -0,0 +1,32 @@ +entity() && $this->user()->can('edit', $this->entity()); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + if (! $this->entity()) { + return []; + } + + return [ + 'name' => 'required', + ]; + } +} diff --git a/app/Models/ProposalCategory.php b/app/Models/ProposalCategory.php index 2da4dda242..2efda4258c 100644 --- a/app/Models/ProposalCategory.php +++ b/app/Models/ProposalCategory.php @@ -22,6 +22,7 @@ class ProposalCategory extends EntityModel * @var array */ protected $fillable = [ + 'name', ]; /** @@ -42,7 +43,7 @@ class ProposalCategory extends EntityModel */ public function getRoute() { - return "/proposal_categories/{$this->public_id}"; + return "/proposals/categories/{$this->public_id}"; } /** diff --git a/app/Models/ProposalSnippet.php b/app/Models/ProposalSnippet.php index 8bd50d6cb2..969399fbee 100644 --- a/app/Models/ProposalSnippet.php +++ b/app/Models/ProposalSnippet.php @@ -42,7 +42,7 @@ class ProposalSnippet extends EntityModel */ public function getRoute() { - return "/proposal_snippets/{$this->public_id}"; + return "/proposals/snippets/{$this->public_id}"; } /** diff --git a/app/Models/ProposalTemplate.php b/app/Models/ProposalTemplate.php index 34dbe0e3dd..551c4a11df 100644 --- a/app/Models/ProposalTemplate.php +++ b/app/Models/ProposalTemplate.php @@ -42,7 +42,7 @@ class ProposalTemplate extends EntityModel */ public function getRoute() { - return "/proposal_templates/{$this->public_id}"; + return "/proposals/templates/{$this->public_id}"; } /** diff --git a/app/Ninja/Repositories/ProposalCategoryRepository.php b/app/Ninja/Repositories/ProposalCategoryRepository.php index 54ef43108b..22c71f72cb 100644 --- a/app/Ninja/Repositories/ProposalCategoryRepository.php +++ b/app/Ninja/Repositories/ProposalCategoryRepository.php @@ -62,7 +62,7 @@ class ProposalCategoryRepository extends BaseRepository public function save($input, $proposal = false) { - $publicId = isset($data['public_id']) ? $data['public_id'] : false; + $publicId = isset($input['public_id']) ? $input['public_id'] : false; if (! $proposal) { $proposal = ProposalCategory::createNew(); diff --git a/resources/views/proposals/categories/edit.blade.php b/resources/views/proposals/categories/edit.blade.php index de9696fc04..1dc61f475a 100644 --- a/resources/views/proposals/categories/edit.blade.php +++ b/resources/views/proposals/categories/edit.blade.php @@ -3,5 +3,47 @@ @section('content') + {!! Former::open($url) + ->addClass('col-lg-10 col-lg-offset-1 warn-on-exit') + ->method($method) + ->rules([ + 'name' => 'required', + ]) !!} + + @if ($category) + {!! Former::populate($category) !!} + @endif + + + {!! Former::text('public_id') !!} + + +
+
+ +
+
+ + {!! Former::text('name') !!} + +
+
+ +
+
+ + +
+ {!! Button::normal(trans('texts.cancel'))->large()->asLinkTo(HTMLUtils::previousUrl('/expense_categories'))->appendIcon(Icon::create('remove-circle')) !!} + {!! Button::success(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk')) !!} +
+ + {!! Former::close() !!} + + @stop