invoiceninja/app/Http/ViewComposers/ProposalComposer.php

49 lines
1,013 B
PHP
Raw Normal View History

2018-02-04 23:41:48 +02:00
<?php
namespace App\Http\ViewComposers;
use Illuminate\View\View;
use App\Models\ProposalSnippet;
2018-02-12 21:21:49 +02:00
use App\Models\Document;
2018-02-04 23:41:48 +02:00
/**
* 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)
{
2018-02-04 23:50:57 +02:00
$snippets = ProposalSnippet::scope()
->with('proposal_category')
->orderBy('name')
->get();
$view->with('snippets', $snippets);
2018-02-12 21:21:49 +02:00
$documents = Document::scope()
->whereNull('invoice_id')
->whereNull('expense_id')
->get();
$data = [];
foreach ($documents as $document) {
$data[] = [
2018-02-13 12:06:50 +02:00
'src' => $document->getProposalUrl(),
2018-02-12 21:21:49 +02:00
'public_id' => $document->public_id,
];
}
$view->with('documents', $data);
2018-02-04 23:41:48 +02:00
}
}