mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Create more date helpers
This commit is contained in:
parent
17b2bc4e69
commit
b7d9ad1808
@ -44,7 +44,7 @@ class InvoiceController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(InvoiceFilters $filters, Builder $builder)
|
public function index(InvoiceFilters $filters, Builder $builder)
|
||||||
{//
|
{//
|
||||||
$invoices = Invoice::filter($filters);
|
$invoices = Invoice::filter($filters)->with('client', 'client.country');
|
||||||
|
|
||||||
if (request()->ajax()) {
|
if (request()->ajax()) {
|
||||||
|
|
||||||
@ -57,9 +57,9 @@ class InvoiceController extends Controller
|
|||||||
->editColumn('status_id', function ($invoice){
|
->editColumn('status_id', function ($invoice){
|
||||||
return Invoice::badgeForStatus($invoice->status);
|
return Invoice::badgeForStatus($invoice->status);
|
||||||
})->editColumn('invoice_date', function ($invoice){
|
})->editColumn('invoice_date', function ($invoice){
|
||||||
return $this->createClientDate($invoice->invoice_date, $invoice->client->timezone()->name)->format($invoice->client->date_format());
|
return $this->formatDate($invoice->invoice_date, $invoice->client->date_format());
|
||||||
})->editColumn('due_date', function ($invoice){
|
})->editColumn('due_date', function ($invoice){
|
||||||
return $this->createClientDate($invoice->due_date, $invoice->client->timezone()->name)->format($invoice->client->date_format());
|
return $this->formatDate($invoice->due_date, $invoice->client->date_format());
|
||||||
})->editColumn('balance', function ($invoice) {
|
})->editColumn('balance', function ($invoice) {
|
||||||
return Number::formatMoney($invoice->balance, $invoice->client->currency(), $invoice->client->country, $invoice->client->getMergedSettings());
|
return Number::formatMoney($invoice->balance, $invoice->client->currency(), $invoice->client->country, $invoice->client->getMergedSettings());
|
||||||
})->editColumn('amount', function ($invoice) {
|
})->editColumn('amount', function ($invoice) {
|
||||||
|
@ -52,6 +52,22 @@ trait MakesDates
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats a date
|
||||||
|
* @param Carbon/String $date Carbon object or date string
|
||||||
|
* @param string $format The date display format
|
||||||
|
* @return string The formatted date
|
||||||
|
*/
|
||||||
|
public function formatDate($date, string $format) :string
|
||||||
|
{
|
||||||
|
|
||||||
|
if(is_string($date))
|
||||||
|
$date = $this->convertToDateObject($date);
|
||||||
|
|
||||||
|
return $date->format($format);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private function convertToDateObject($date)
|
private function convertToDateObject($date)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -59,4 +75,6 @@ trait MakesDates
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -67,7 +67,7 @@ class RandomDataSeeder extends Seeder
|
|||||||
ClientContact::create([
|
ClientContact::create([
|
||||||
'first_name' => $faker->firstName,
|
'first_name' => $faker->firstName,
|
||||||
'last_name' => $faker->lastName,
|
'last_name' => $faker->lastName,
|
||||||
'email' => $faker->email,
|
'email' => config('ninja.testvars.username'),
|
||||||
'company_id' => $company->id,
|
'company_id' => $company->id,
|
||||||
'password' => Hash::make(config('ninja.testvars.password')),
|
'password' => Hash::make(config('ninja.testvars.password')),
|
||||||
'email_verified_at' => now(),
|
'email_verified_at' => now(),
|
||||||
|
Loading…
Reference in New Issue
Block a user