1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-17 16:42:48 +01:00

Added view presenters

This commit is contained in:
Hillel Coren 2015-11-06 12:59:53 +02:00
parent aa69a17232
commit 15b17dfeed
10 changed files with 94 additions and 27 deletions

View File

@ -8,10 +8,14 @@ use Event;
use App;
use App\Events\UserSettingsChanged;
use Illuminate\Database\Eloquent\SoftDeletes;
use Laracasts\Presenter\PresentableTrait;
class Account extends Eloquent
{
use PresentableTrait;
use SoftDeletes;
protected $presenter = 'App\Ninja\Presenters\AccountPresenter';
protected $dates = ['deleted_at'];
protected $hidden = ['ip'];

View File

@ -91,6 +91,7 @@ class ContactMailer extends Mailer
'entityType' => $invoice->getEntityType(),
'invoiceId' => $invoice->id,
'invitation' => $invitation,
'account' => $account,
];
if ($account->attatchPDF()) {
@ -137,11 +138,12 @@ class ContactMailer extends Mailer
'account' => $account,
'client' => $client,
'invitation' => $invitation,
'amount' => $payment->amount
'amount' => $payment->amount,
];
$data = [
'body' => $this->processVariables($emailTemplate, $variables)
'body' => $this->processVariables($emailTemplate, $variables),
'account' => $account,
];
if ($account->attatchPDF()) {

View File

@ -0,0 +1,12 @@
<?php namespace App\Ninja\Presenters;
use Laracasts\Presenter\Presenter;
class AccountPresenter extends Presenter {
public function name()
{
return $this->entity->name ?: trans('texts.untitled_account');
}
}

View File

@ -26,7 +26,7 @@ class AccountTransformer extends TransformerAbstract
{
return [
'account_key' => $account->account_key,
'name' => $account->name,
'name' => $account->present()->name,
];
}
}

View File

@ -27,7 +27,7 @@ class UserAccountTransformer extends TransformerAbstract
{
return [
'account_key' => $user->account->account_key,
'name' => $user->account->name,
'name' => $user->account->present()->name,
'token' => $user->account->getToken($this->tokenName),
];
}

View File

@ -58,7 +58,8 @@
"meebio/omnipay-secure-trading": "dev-master",
"justinbusschau/omnipay-secpay": "~2.0",
"labs7in0/omnipay-wechat": "dev-master",
"collizo4sky/omnipay-wepay": "~1.0"
"collizo4sky/omnipay-wepay": "~1.0",
"laracasts/presenter": "dev-master"
},
"require-dev": {
"phpunit/phpunit": "~4.0",

83
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "9b0cd6db7a2a2e16ffb1711043005f2b",
"hash": "4c2d5d48a648e380f3acf2943b91e6bc",
"packages": [
{
"name": "agmscode/omnipay-agms",
@ -176,12 +176,12 @@
"source": {
"type": "git",
"url": "https://github.com/formers/former.git",
"reference": "9e75217536bf6c377318e5a6f68d4c1f96a8ae3b"
"reference": "795f7b9b200a4ff4a33b37a96eaaab0229e36325"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/formers/former/zipball/9e75217536bf6c377318e5a6f68d4c1f96a8ae3b",
"reference": "9e75217536bf6c377318e5a6f68d4c1f96a8ae3b",
"url": "https://api.github.com/repos/formers/former/zipball/795f7b9b200a4ff4a33b37a96eaaab0229e36325",
"reference": "795f7b9b200a4ff4a33b37a96eaaab0229e36325",
"shasum": ""
},
"require": {
@ -227,7 +227,7 @@
"foundation",
"laravel"
],
"time": "2015-09-24 15:56:30"
"time": "2015-11-05 15:53:52"
},
{
"name": "anahkiasen/html-object",
@ -2221,12 +2221,12 @@
"source": {
"type": "git",
"url": "https://github.com/Intervention/image.git",
"reference": "33f848674c96b82b050fde2806ba4e55ee88078f"
"reference": "2d8de6577b86c8b3bf49b6578d659ba9ee21fcc1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Intervention/image/zipball/33f848674c96b82b050fde2806ba4e55ee88078f",
"reference": "33f848674c96b82b050fde2806ba4e55ee88078f",
"url": "https://api.github.com/repos/Intervention/image/zipball/2d8de6577b86c8b3bf49b6578d659ba9ee21fcc1",
"reference": "2d8de6577b86c8b3bf49b6578d659ba9ee21fcc1",
"shasum": ""
},
"require": {
@ -2275,7 +2275,7 @@
"thumbnail",
"watermark"
],
"time": "2015-11-04 14:06:13"
"time": "2015-11-05 18:30:26"
},
{
"name": "ircmaxell/password-compat",
@ -2608,6 +2608,52 @@
],
"time": "2015-10-27 05:12:08"
},
{
"name": "laracasts/presenter",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/laracasts/Presenter.git",
"reference": "b284f3137f990efd6e95df49d254f1ccc4541e92"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laracasts/Presenter/zipball/b284f3137f990efd6e95df49d254f1ccc4541e92",
"reference": "b284f3137f990efd6e95df49d254f1ccc4541e92",
"shasum": ""
},
"require": {
"illuminate/support": "~5.0",
"php": ">=5.4.0"
},
"require-dev": {
"mockery/mockery": "~0.9",
"phpspec/phpspec": "~2.0"
},
"type": "library",
"autoload": {
"psr-0": {
"Laracasts\\Presenter": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jeffrey Way",
"email": "jeffrey@laracasts.com"
}
],
"description": "Simple view presenters",
"keywords": [
"laravel",
"presenter",
"view"
],
"time": "2014-09-13 13:18:07"
},
{
"name": "laravel/framework",
"version": "v5.0.33",
@ -3501,16 +3547,16 @@
},
{
"name": "nesbot/carbon",
"version": "1.20.0",
"version": "1.21.0",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
"reference": "bfd3eaba109c9a2405c92174c8e17f20c2b9caf3"
"reference": "7b08ec6f75791e130012f206e3f7b0e76e18e3d7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/bfd3eaba109c9a2405c92174c8e17f20c2b9caf3",
"reference": "bfd3eaba109c9a2405c92174c8e17f20c2b9caf3",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/7b08ec6f75791e130012f206e3f7b0e76e18e3d7",
"reference": "7b08ec6f75791e130012f206e3f7b0e76e18e3d7",
"shasum": ""
},
"require": {
@ -3518,12 +3564,12 @@
"symfony/translation": "~2.6|~3.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
"phpunit/phpunit": "~4.0|~5.0"
},
"type": "library",
"autoload": {
"psr-0": {
"Carbon": "src"
"psr-4": {
"Carbon\\": "src/Carbon/"
}
},
"notification-url": "https://packagist.org/downloads/",
@ -3544,7 +3590,7 @@
"datetime",
"time"
],
"time": "2015-06-25 04:19:39"
"time": "2015-11-04 20:07:17"
},
{
"name": "nikic/php-parser",
@ -8330,7 +8376,8 @@
"descubraomundo/omnipay-pagarme": 20,
"dercoder/omnipay-paysafecard": 20,
"meebio/omnipay-secure-trading": 20,
"labs7in0/omnipay-wechat": 20
"labs7in0/omnipay-wechat": 20,
"laracasts/presenter": 20
},
"prefer-stable": false,
"prefer-lowest": false,

View File

@ -14,7 +14,7 @@ class UserTableSeeder extends Seeder
Eloquent::unguard();
$account = Account::create([
'name' => 'Test Account',
//'name' => 'Test Account',
'account_key' => str_random(RANDOM_KEY_LENGTH),
'timezone_id' => 1,
]);

View File

@ -907,5 +907,6 @@ return array(
'restore_recurring_invoice' => 'Restore Recurring Invoice',
'restored_recurring_invoice' => 'Successfully restored recurring invoice',
'archived' => 'Archived',
'untitled_account' => 'Untitled Company',
);

View File

@ -5,13 +5,13 @@
"description":"View your {{ $entityType }}",
"action": {
"@type": "ViewAction",
"url": "{{{ $link }}}",
"url": "{!! $link !!}",
"name": "View {{ $entityType }}"
},
"publisher": {
"@type": "Organization",
"name": "Invoice Ninja",
"url": "{{{ NINJA_WEB_URL }}}"
"url": "{!! NINJA_WEB_URL !!}"
}
}
</script>