Ask, reply and learn. Join the community of Akaunting.
I am starting to try and overide some of the outputs.. but running into problems with the docs... Bits seem to be missing like where some of the files are supposed to be.
I was wondering if anyone was willing to fill int he gaps in the docs, or was willing to reply here with a working example?
Trying to bump this..
running with a clean 1.3.7 zip.. and following the documentation to teh letter (except when teh guidance was missing!)
I set the .env to have debug true and development env
I get
"Class 'Modules\FooBar\Providers\View' not found"
My Customer View Composer is in \modules\FooBar\Http\ViewComposers\CustomersViewComposer.php
The actual cusotmers view is simply a copy of the base customer view with no changes
I'm assuming its just bad documentation?
Ah fixed it..
for future visitors..
when you create the module - if you want to override output - you also need to add
use Illuminate\Support\Facades\View;
to the top of the FooBar Service provider
I spoke too soon.. now it throws
Class Modules\FooBar\Http\ViewComposers\Customers does not exist
it does, but clearly somewhere its not being used
Make sure that the namespace of Customers file is correct.
Well I think it is. it was directly from the example.. and the View composer is in Http/ViewComposers
phew.. ok it turned out to be a typo in the boot code
Now the next challenge - how to override the output for invoice printing.. since the path for pringing invoices is '/incomes/invoices/<invoice id>/print it doesn't lend itself to the 'incomes.invoices.print'
Or not, the moment I worked out it needed to over-ride incomes.invoices.invoice it failed
code for service provider boot
namespace Modules\FooBar\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Factory;
use App\Models\Income\Invoice;
use View;
use Illuminate\Support\Facades\Log;
class FooBarServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;
/**
* Boot the application events.
*
* @return void
*/
public function boot()
{
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
$this->registerFactories();
Log::debug('in FooBar SP boot.');
View::composer([
'incomes.invoices.invoice',
], 'Modules\FooBar\Http\ViewComposers\Invoices');
}
and view composer (invoice.blade is simply copied from teh default at the moment)
<?php
namespace Modules\FooBar\Http\ViewComposers;
use Illuminate\View\View;
use Illuminate\Support\Facades\Log;
class Invoices
{
/**
* Bind data to the view.
*
* @param View $view
* @return mixed
*/
public function compose(View $view)
{
// Override just the 'content' section
//$view->getFactory()->startSection('content', view('foobar::customers.create'));
// Override the whole file
$view->setPath(view('foobar::invoices.invoice')->getPath());
// Push to a stack
//$view->getFactory()->startPush('scripts', view('foobar::script'));
}
}
Showing 1 to 10 of 15 discussions