68 lines
1.6 KiB
PHP
Raw Normal View History

2017-09-14 22:21:00 +03:00
<?php
namespace App\Http\ViewComposers;
2017-12-18 17:14:59 +03:00
use Date;
2019-11-16 10:21:14 +03:00
use Illuminate\Support\Str;
2017-09-14 22:21:00 +03:00
use Illuminate\View\View;
class Index
{
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{
$limits = ['10' => '10', '25' => '25', '50' => '50', '100' => '100'];
2017-12-18 17:14:59 +03:00
$now = Date::now();
$this_year = $now->year;
$years = [];
2018-09-08 17:04:51 +03:00
$y = $now->addYears(2);
2017-12-18 17:14:59 +03:00
for ($i = 0; $i < 10; $i++) {
$years[$y->year] = $y->year;
$y->subYear();
}
$view->with(['limits' => $limits, 'this_year' => $this_year, 'years' => $years]);
2019-11-16 10:21:14 +03:00
// Add Bulk Action
$module = false;
$view_name = $view->getName();
if (Str::contains($view_name, '::')) {
$names = explode('::', $view_name);
$params = explode('.', $names[1]);
2019-11-16 10:21:14 +03:00
$group = $params[0];
$type = $params[1];
2019-11-16 10:21:14 +03:00
// Check is module
$module = module($names[0]);
} else {
$params = explode('.', $view_name);
$group = $params[0];
$type = $params[1];
}
if ($module instanceof \Akaunting\Module\Module) {
$class = 'Modules\\' . $module->getStudlyName() . '\BulkActions\\' . ucfirst($group) . '\\' . ucfirst($type);
2019-11-16 10:21:14 +03:00
} else {
$class = 'App\BulkActions\\' . ucfirst($group) . '\\' . ucfirst($type);
}
if (class_exists($class)) {
$bulk_actions = app($class);
$view->with(['bulk_actions' => $bulk_actions->actions]);
}
2017-09-14 22:21:00 +03:00
}
}