mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Ensure models are touched appropriately"
This commit is contained in:
parent
23f12ef27c
commit
41b85b3fb3
@ -7,6 +7,7 @@ use App\Events\Invoice\InvoiceWasCreated;
|
||||
use App\Factory\InvoiceFactory;
|
||||
use App\Factory\InvoiceItemFactory;
|
||||
use App\Helpers\Invoice\InvoiceSum;
|
||||
use App\Jobs\Ninja\CompanySizeCheck;
|
||||
use App\Jobs\Util\VersionCheck;
|
||||
use App\Models\CompanyToken;
|
||||
use App\Models\Country;
|
||||
@ -79,6 +80,9 @@ class DemoMode extends Command
|
||||
$this->createSmallAccount();
|
||||
|
||||
VersionCheck::dispatchNow();
|
||||
|
||||
CompanySizeCheck::dispatchNow();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -360,7 +364,7 @@ class DemoMode extends Command
|
||||
|
||||
$this->invoice_repo->markSent($invoice);
|
||||
|
||||
if (rand(0, 1)) {
|
||||
if ((bool)rand(0, 2)) {
|
||||
|
||||
$invoice = $invoice->service()->markPaid()->save();
|
||||
|
||||
|
@ -27,6 +27,8 @@ class CompanySettings extends BaseSettings
|
||||
public $auto_archive_invoice = false;
|
||||
public $lock_sent_invoices = false;
|
||||
|
||||
public $lock_invoices = 'off'; //off,when_sent,when_paid
|
||||
|
||||
public $enable_client_portal_tasks = false;
|
||||
public $enable_client_portal_password = false;
|
||||
public $enable_client_portal = true; //implemented
|
||||
@ -236,6 +238,7 @@ class CompanySettings extends BaseSettings
|
||||
public $client_portal_privacy_policy = '';
|
||||
|
||||
public static $casts = [
|
||||
'lock_invoices' => 'string',
|
||||
'client_portal_terms' => 'string',
|
||||
'client_portal_privacy_policy' => 'string',
|
||||
'client_can_register' => 'bool',
|
||||
|
@ -34,7 +34,7 @@ class CompanyFactory
|
||||
//$company->custom_fields = (object) ['invoice1' => '1', 'invoice2' => '2', 'client1'=>'3'];
|
||||
$company->custom_fields = (object) [];
|
||||
$company->subdomain = '';
|
||||
$company->enabled_modules = 4095;
|
||||
$company->enabled_modules = 4095; //16383
|
||||
|
||||
return $company;
|
||||
}
|
||||
|
@ -23,6 +23,9 @@ class PingController extends BaseController
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return response()->json(['company_name' => auth()->user()->getCompany()->present()->name() - auth()->user()->present()->name()], 200);
|
||||
return response()->json(
|
||||
['company_name' => auth()->user()->getCompany()->present()->name(),
|
||||
'user_name' => auth()->user()->present()->name(),
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ class PasswordProtection
|
||||
}
|
||||
} elseif (Cache::get(auth()->user()->email."_logged_in")) {
|
||||
Cache::pull(auth()->user()->email."_logged_in");
|
||||
Cache::add(auth()->user()->email."_logged_in", Str::random(64), now()->addMinutes(10));
|
||||
Cache::add(auth()->user()->email."_logged_in", Str::random(64), now()->addMinutes(30));
|
||||
|
||||
return $next($request);
|
||||
} else {
|
||||
@ -52,7 +52,7 @@ class PasswordProtection
|
||||
return response()->json($error, 412);
|
||||
}
|
||||
|
||||
Cache::add(auth()->user()->email."_logged_in", Str::random(64), now()->addMinutes(10));
|
||||
Cache::add(auth()->user()->email."_logged_in", Str::random(64), now()->addMinutes(30));
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
@ -116,6 +116,8 @@ class Client extends BaseModel implements HasLocalePreference
|
||||
'deleted_at' => 'timestamp',
|
||||
];
|
||||
|
||||
protected $touches = ['company'];
|
||||
|
||||
public function getEntityType()
|
||||
{
|
||||
return Client::class;
|
||||
|
@ -37,6 +37,8 @@ class ClientContact extends Authenticatable implements HasLocalePreference
|
||||
/* Used to authenticate a contact */
|
||||
protected $guard = 'contact';
|
||||
|
||||
protected $touches = ['client'];
|
||||
|
||||
/* Allow microtime timestamps */
|
||||
protected $dateFormat = 'Y-m-d H:i:s.u';
|
||||
|
||||
|
@ -65,6 +65,22 @@ class Company extends BaseModel
|
||||
const ENTITY_RECURRING_TASK = 'task';
|
||||
const ENTITY_RECURRING_QUOTE = 'recurring_quote';
|
||||
|
||||
// const int kModuleRecurringInvoices = 1;
|
||||
// const int kModuleCredits = 2;
|
||||
// const int kModuleQuotes = 4;
|
||||
// const int kModuleTasks = 8;
|
||||
// const int kModuleExpenses = 16;
|
||||
// const int kModuleProjects = 32;
|
||||
// const int kModuleVendors = 64;
|
||||
// const int kModuleTickets = 128;
|
||||
// const int kModuleProposals = 256;
|
||||
// const int kModuleRecurringExpenses = 512;
|
||||
// const int kModuleRecurringTasks = 1024;
|
||||
// const int kModuleRecurringQuotes = 2048;
|
||||
// kModuleInvoices = 4096;
|
||||
// kModulePayments = 8192;
|
||||
// 16383
|
||||
|
||||
protected $presenter = 'App\Models\Presenters\CompanyPresenter';
|
||||
|
||||
protected $fillable = [
|
||||
|
@ -58,6 +58,8 @@ class CompanyGateway extends BaseModel
|
||||
// return json_decode($this->attributes['fees_and_limits']);
|
||||
// }
|
||||
|
||||
protected $touches = ['company'];
|
||||
|
||||
public function getEntityType()
|
||||
{
|
||||
return CompanyGateway::class;
|
||||
|
@ -27,6 +27,8 @@ class CompanyLedger extends Model
|
||||
'deleted_at' => 'timestamp',
|
||||
];
|
||||
|
||||
protected $touches = ['company'];
|
||||
|
||||
public function getEntityType()
|
||||
{
|
||||
return CompanyLedger::class;
|
||||
|
@ -27,6 +27,9 @@ class CompanyToken extends BaseModel
|
||||
protected $with = [
|
||||
];
|
||||
|
||||
protected $touches = ['company'];
|
||||
|
||||
|
||||
public function getEntityType()
|
||||
{
|
||||
return CompanyToken::class;
|
||||
|
@ -48,6 +48,8 @@ class CompanyUser extends Pivot
|
||||
'slack_webhook_url',
|
||||
];
|
||||
|
||||
protected $touches = ['company'];
|
||||
|
||||
public function getEntityType()
|
||||
{
|
||||
return CompanyUser::class;
|
||||
|
@ -78,6 +78,8 @@ class Credit extends BaseModel
|
||||
'deleted_at' => 'timestamp',
|
||||
];
|
||||
|
||||
protected $touches = ['company'];
|
||||
|
||||
const STATUS_DRAFT = 1;
|
||||
const STATUS_SENT = 2;
|
||||
const STATUS_PARTIAL = 3;
|
||||
|
@ -37,6 +37,8 @@ class CreditInvitation extends BaseModel
|
||||
// 'company',
|
||||
];
|
||||
|
||||
protected $touches = ['credit'];
|
||||
|
||||
public function getEntityType()
|
||||
{
|
||||
return CreditInvitation::class;
|
||||
|
@ -59,6 +59,8 @@ class Expense extends BaseModel
|
||||
'created_at' => 'timestamp',
|
||||
'deleted_at' => 'timestamp',
|
||||
];
|
||||
|
||||
protected $touches = ['company'];
|
||||
|
||||
public function getEntityType()
|
||||
{
|
||||
|
@ -40,6 +40,8 @@ class GroupSetting extends StaticModel
|
||||
'settings'
|
||||
];
|
||||
|
||||
protected $touches = ['company'];
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
|
@ -56,6 +56,8 @@ class Invoice extends BaseModel
|
||||
|
||||
protected $presenter = 'App\Models\Presenters\InvoicePresenter';
|
||||
|
||||
protected $touches = ['company'];
|
||||
|
||||
protected $hidden = [
|
||||
'id',
|
||||
'private_notes',
|
||||
|
@ -36,6 +36,9 @@ class InvoiceInvitation extends BaseModel
|
||||
// 'company',
|
||||
];
|
||||
|
||||
protected $touches = ['invoice'];
|
||||
|
||||
|
||||
public function getEntityType()
|
||||
{
|
||||
return InvoiceInvitation::class;
|
||||
|
@ -81,6 +81,8 @@ class Payment extends BaseModel
|
||||
'paymentables',
|
||||
];
|
||||
|
||||
protected $touches = ['company'];
|
||||
|
||||
public function getEntityType()
|
||||
{
|
||||
return Payment::class;
|
||||
|
@ -40,6 +40,8 @@ class Product extends BaseModel
|
||||
'tax_rate3',
|
||||
];
|
||||
|
||||
protected $touches = ['company'];
|
||||
|
||||
public function getEntityType()
|
||||
{
|
||||
return Product::class;
|
||||
|
@ -42,6 +42,8 @@ class Project extends BaseModel
|
||||
return Project::class;
|
||||
}
|
||||
|
||||
protected $touches = ['company'];
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
|
@ -22,6 +22,8 @@ class Proposal extends BaseModel
|
||||
'id',
|
||||
];
|
||||
|
||||
protected $touches = ['company'];
|
||||
|
||||
public function getEntityType()
|
||||
{
|
||||
return Proposal::class;
|
||||
|
@ -42,6 +42,8 @@ class Quote extends BaseModel
|
||||
|
||||
protected $presenter = 'App\Models\Presenters\QuotePresenter';
|
||||
|
||||
protected $touches = ['company'];
|
||||
|
||||
protected $fillable = [
|
||||
'assigned_user_id',
|
||||
'number',
|
||||
|
@ -31,6 +31,8 @@ class QuoteInvitation extends BaseModel
|
||||
'client_contact_id',
|
||||
];
|
||||
|
||||
protected $touches = ['quote'];
|
||||
|
||||
public function getEntityType()
|
||||
{
|
||||
return QuoteInvitation::class;
|
||||
|
@ -112,6 +112,8 @@ class RecurringInvoice extends BaseModel
|
||||
'status'
|
||||
];
|
||||
|
||||
protected $touches = ['company'];
|
||||
|
||||
public function getEntityType()
|
||||
{
|
||||
return RecurringInvoice::class;
|
||||
|
@ -18,6 +18,8 @@ class RecurringInvoiceInvitation extends BaseModel
|
||||
{
|
||||
use MakesDates;
|
||||
|
||||
protected $touches = ['recurring_invoice'];
|
||||
|
||||
public function getEntityType()
|
||||
{
|
||||
return RecurringInvoiceInvitation::class;
|
||||
|
@ -81,6 +81,8 @@ class RecurringQuote extends BaseModel
|
||||
'start_date',
|
||||
];
|
||||
|
||||
protected $touches = ['company'];
|
||||
|
||||
protected $casts = [
|
||||
'line_items' => 'object',
|
||||
'backup' => 'object',
|
||||
|
@ -30,6 +30,8 @@ class Task extends BaseModel
|
||||
'time_log',
|
||||
];
|
||||
|
||||
protected $touches = ['company'];
|
||||
|
||||
protected $casts = [
|
||||
'updated_at' => 'timestamp',
|
||||
'created_at' => 'timestamp',
|
||||
@ -40,6 +42,11 @@ class Task extends BaseModel
|
||||
return Task::class;
|
||||
}
|
||||
|
||||
public function company()
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
public function documents()
|
||||
{
|
||||
return $this->morphMany(Document::class, 'documentable');
|
||||
|
@ -53,6 +53,8 @@ class Vendor extends BaseModel
|
||||
'deleted_at' => 'timestamp',
|
||||
];
|
||||
|
||||
protected $touches = ['company'];
|
||||
|
||||
protected $with = [
|
||||
// 'contacts',
|
||||
];
|
||||
|
@ -37,6 +37,8 @@ class VendorContact extends Authenticatable implements HasLocalePreference
|
||||
/* Used to authenticate a vendor */
|
||||
protected $guard = 'vendor';
|
||||
|
||||
protected $touches = ['vendor'];
|
||||
|
||||
/* Allow microtime timestamps */
|
||||
protected $dateFormat = 'Y-m-d H:i:s.u';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user