Proposals

This commit is contained in:
Hillel Coren 2018-02-04 23:41:48 +02:00
parent 33c37842cc
commit 2000e66c9d
6 changed files with 36 additions and 9 deletions

View File

@ -8,7 +8,6 @@ use App\Http\Requests\UpdateProposalRequest;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\Proposal; use App\Models\Proposal;
use App\Models\ProposalTemplate; use App\Models\ProposalTemplate;
use App\Models\ProposalSnippet;
use App\Ninja\Datatables\ProposalDatatable; use App\Ninja\Datatables\ProposalDatatable;
use App\Ninja\Repositories\ProposalRepository; use App\Ninja\Repositories\ProposalRepository;
use App\Services\ProposalService; use App\Services\ProposalService;
@ -64,7 +63,6 @@ class ProposalController extends BaseController
'quotes' => Invoice::scope()->with('client.contacts')->quotes()->orderBy('id')->get(), 'quotes' => Invoice::scope()->with('client.contacts')->quotes()->orderBy('id')->get(),
'templates' => ProposalTemplate::whereAccountId($account->id)->orWhereNull('account_id')->orderBy('name')->get(), 'templates' => ProposalTemplate::whereAccountId($account->id)->orWhereNull('account_id')->orderBy('name')->get(),
'quotePublicId' => $request->quote_id, 'quotePublicId' => $request->quote_id,
'snippets' => ProposalSnippet::scope()->with('proposal_category')->orderBy('name')->get(),
]; ];
return View::make('proposals.edit', $data); return View::make('proposals.edit', $data);
@ -92,7 +90,6 @@ class ProposalController extends BaseController
'templates' => ProposalTemplate::whereAccountId($account->id)->orWhereNull('account_id')->orderBy('name')->get(), 'templates' => ProposalTemplate::whereAccountId($account->id)->orWhereNull('account_id')->orderBy('name')->get(),
'quotePublicId' => $proposal->quote ? $proposal->quote->public_id : null, 'quotePublicId' => $proposal->quote ? $proposal->quote->public_id : null,
'templatePublicId' => $proposal->proposal_template ? $proposal->proposal_template->public_id : null, 'templatePublicId' => $proposal->proposal_template ? $proposal->proposal_template->public_id : null,
'snippets' => ProposalSnippet::scope()->with('proposal_category')->orderBy('name')->get(),
]; ];
return View::make('proposals.edit', $data); return View::make('proposals.edit', $data);

View File

@ -60,7 +60,6 @@ class ProposalSnippetController extends BaseController
'title' => trans('texts.new_proposal_snippet'), 'title' => trans('texts.new_proposal_snippet'),
'categories' => ProposalCategory::scope()->orderBy('name')->get(), 'categories' => ProposalCategory::scope()->orderBy('name')->get(),
'categoryPublicId' => 0, 'categoryPublicId' => 0,
'snippets' => ProposalSnippet::scope()->with('proposal_category')->orderBy('name')->get(),
'icons' => $this->getIcons(), 'icons' => $this->getIcons(),
]; ];
@ -86,7 +85,6 @@ class ProposalSnippetController extends BaseController
'title' => trans('texts.edit_proposal_snippet'), 'title' => trans('texts.edit_proposal_snippet'),
'categories' => ProposalCategory::scope()->orderBy('name')->get(), 'categories' => ProposalCategory::scope()->orderBy('name')->get(),
'categoryPublicId' => $proposalSnippet->proposal_category ? $proposalSnippet->proposal_category->public_id : null, 'categoryPublicId' => $proposalSnippet->proposal_category ? $proposalSnippet->proposal_category->public_id : null,
'snippets' => ProposalSnippet::scope()->with('proposal_category')->orderBy('name')->get(),
'icons' => $this->getIcons(), 'icons' => $this->getIcons(),
]; ];

View File

@ -7,7 +7,6 @@ use App\Http\Requests\ProposalTemplateRequest;
use App\Http\Requests\UpdateProposalTemplateRequest; use App\Http\Requests\UpdateProposalTemplateRequest;
use App\Models\Invoice; use App\Models\Invoice;
use App\Models\ProposalTemplate; use App\Models\ProposalTemplate;
use App\Models\ProposalSnippet;
use App\Ninja\Datatables\ProposalTemplateDatatable; use App\Ninja\Datatables\ProposalTemplateDatatable;
use App\Ninja\Repositories\ProposalTemplateRepository; use App\Ninja\Repositories\ProposalTemplateRepository;
use App\Services\ProposalTemplateService; use App\Services\ProposalTemplateService;
@ -59,7 +58,6 @@ class ProposalTemplateController extends BaseController
'url' => 'proposals/templates', 'url' => 'proposals/templates',
'title' => trans('texts.new_proposal_template'), 'title' => trans('texts.new_proposal_template'),
'templates' => ProposalTemplate::scope()->orderBy('name')->get(), 'templates' => ProposalTemplate::scope()->orderBy('name')->get(),
'snippets' => ProposalSnippet::scope()->with('proposal_category')->orderBy('name')->get(),
]; ];
return View::make('proposals/templates/edit', $data); return View::make('proposals/templates/edit', $data);
@ -83,7 +81,6 @@ class ProposalTemplateController extends BaseController
'url' => 'proposals/templates/' . $proposalTemplate->public_id, 'url' => 'proposals/templates/' . $proposalTemplate->public_id,
'title' => trans('texts.edit_proposal_template'), 'title' => trans('texts.edit_proposal_template'),
'templates' => ProposalTemplate::scope()->orderBy('name')->get(), 'templates' => ProposalTemplate::scope()->orderBy('name')->get(),
'snippets' => ProposalSnippet::scope()->with('proposal_category')->orderBy('name')->get(),
]; ];
return View::make('proposals/templates/edit', $data); return View::make('proposals/templates/edit', $data);

View File

@ -0,0 +1,26 @@
<?php
namespace App\Http\ViewComposers;
use Illuminate\View\View;
use App\Models\ProposalSnippet;
/**
* ClientPortalHeaderComposer.php.
*
* @copyright See LICENSE file that was distributed with this source code.
*/
class ProposalComposer
{
/**
* Bind data to the view.
*
* @param View $view
*
* @return void
*/
public function compose(View $view)
{
$view->with('snippets', ProposalSnippet::scope()->with('proposal_category')->orderBy('name')->get());
}
}

View File

@ -31,7 +31,7 @@ class ProposalSnippetDatatable extends EntityDatatable
return $model->category; return $model->category;
} }
return link_to("proposals/categories/{$model->category_public_id}/edit", $model->category)->toHtml(); return link_to("proposals/categories/{$model->category_public_id}/edit", $model->category ?: ' ')->toHtml();
}, },
], ],
[ [

View File

@ -42,6 +42,15 @@ class ComposerServiceProvider extends ServiceProvider
], ],
'App\Http\ViewComposers\ClientPortalHeaderComposer' 'App\Http\ViewComposers\ClientPortalHeaderComposer'
); );
view()->composer(
[
'proposals.edit',
'proposals.templates.edit',
'proposals.snippets.edit',
],
'App\Http\ViewComposers\ProposalComposer'
);
} }
/** /**