fixed export file name

This commit is contained in:
denisdulici 2020-02-12 12:18:08 +03:00
parent 3dbb2b33e6
commit 2c7b15b331
17 changed files with 56 additions and 15 deletions

View File

@ -195,7 +195,7 @@ abstract class Report
public function export()
{
return \Excel::download(new Export($this->views['content'], $this), $this->model->name . '.xlsx');
return \Excel::download(new Export($this->views['content'], $this), \Str::filename($this->model->name) . '.xlsx');
}
public function setYear()

View File

@ -73,6 +73,6 @@ class Bills extends BulkAction
{
$selected = $this->getSelectedInput($request);
return \Excel::download(new Export($selected), trans_choice('general.bills', 2) . '.xlsx');
return \Excel::download(new Export($selected), \Str::filename(trans_choice('general.bills', 2)) . '.xlsx');
}
}

View File

@ -31,6 +31,6 @@ class Payments extends BulkAction
{
$selected = $this->getSelectedInput($request);
return \Excel::download(new Export($selected), trans_choice('general.payments', 2) . '.xlsx');
return \Excel::download(new Export($selected), \Str::filename(trans_choice('general.payments', 2)) . '.xlsx');
}
}

View File

@ -46,6 +46,6 @@ class Vendors extends BulkAction
{
$selected = $this->getSelectedInput($request);
return \Excel::download(new Export($selected), trans_choice('general.vendors', 2) . '.xlsx');
return \Excel::download(new Export($selected), \Str::filename(trans_choice('general.vendors', 2)) . '.xlsx');
}
}

View File

@ -46,6 +46,6 @@ class Customers extends BulkAction
{
$selected = $this->getSelectedInput($request);
return \Excel::download(new Export($selected), trans_choice('general.customers', 2) . '.xlsx');
return \Excel::download(new Export($selected), \Str::filename(trans_choice('general.customers', 2)) . '.xlsx');
}
}

View File

@ -87,6 +87,6 @@ class Invoices extends BulkAction
{
$selected = $this->getSelectedInput($request);
return \Excel::download(new Export($selected), trans_choice('general.invoices', 2) . '.xlsx');
return \Excel::download(new Export($selected), \Str::filename(trans_choice('general.invoices', 2)) . '.xlsx');
}
}

View File

@ -31,6 +31,6 @@ class Revenues extends BulkAction
{
$selected = $this->getSelectedInput($request);
return \Excel::download(new Export($selected), trans_choice('general.revenues', 2) . '.xlsx');
return \Excel::download(new Export($selected), \Str::filename(trans_choice('general.revenues', 2)) . '.xlsx');
}
}

View File

@ -84,6 +84,6 @@ class Transactions extends Controller
*/
public function export()
{
return \Excel::download(new Export(), trans_choice('general.transactions', 2) . '.xlsx');
return \Excel::download(new Export(), \Str::filename(trans_choice('general.transactions', 2)) . '.xlsx');
}
}

View File

@ -235,7 +235,7 @@ class Items extends Controller
*/
public function export()
{
return \Excel::download(new Export(), trans_choice('general.items', 2) . '.xlsx');
return \Excel::download(new Export(), \Str::filename(trans_choice('general.items', 2)) . '.xlsx');
}
public function autocomplete()

View File

@ -268,7 +268,7 @@ class Bills extends Controller
*/
public function export()
{
return \Excel::download(new Export(), trans_choice('general.bills', 2) . '.xlsx');
return \Excel::download(new Export(), \Str::filename(trans_choice('general.bills', 2)) . '.xlsx');
}
/**

View File

@ -228,6 +228,6 @@ class Payments extends Controller
*/
public function export()
{
return \Excel::download(new Export(), trans_choice('general.payments', 2) . '.xlsx');
return \Excel::download(new Export(), \Str::filename(trans_choice('general.payments', 2)) . '.xlsx');
}
}

View File

@ -277,7 +277,7 @@ class Vendors extends Controller
*/
public function export()
{
return \Excel::download(new Export(), trans_choice('general.vendors', 2) . '.xlsx');
return \Excel::download(new Export(), \Str::filename(trans_choice('general.vendors', 2)) . '.xlsx');
}
public function currency(Contact $vendor)

View File

@ -283,7 +283,7 @@ class Customers extends Controller
*/
public function export()
{
return \Excel::download(new Export(), trans_choice('general.customers', 2) . '.xlsx');
return \Excel::download(new Export(), \Str::filename(trans_choice('general.customers', 2)) . '.xlsx');
}
public function currency(Contact $customer)

View File

@ -274,7 +274,7 @@ class Invoices extends Controller
*/
public function export()
{
return \Excel::download(new Export(), trans_choice('general.invoices', 2) . '.xlsx');
return \Excel::download(new Export(), \Str::filename(trans_choice('general.invoices', 2)) . '.xlsx');
}
/**

View File

@ -228,6 +228,6 @@ class Revenues extends Controller
*/
public function export()
{
return \Excel::download(new Export(), trans_choice('general.revenues', 2) . '.xlsx');
return \Excel::download(new Export(), \Str::filename(trans_choice('general.revenues', 2)) . '.xlsx');
}
}

40
app/Providers/Macro.php Normal file
View File

@ -0,0 +1,40 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;
class Macro extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Str::macro('filename', function ($string, $separator = '-') {
// Replace @ with the word 'at'
$string = str_replace('@', $separator.'at'.$separator, $string);
// Remove all characters that are not the separator, letters, numbers, or whitespace.
$string = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', $string);
// Remove multiple whitespaces
$string = preg_replace('/\s+/', ' ', $string);
return $string;
});
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}

View File

@ -174,6 +174,7 @@ return [
// App\Providers\Broadcast::class,
App\Providers\Event::class,
App\Providers\Form::class,
App\Providers\Macro::class,
App\Providers\Observer::class,
App\Providers\Route::class,
App\Providers\Validation::class,