All kinds of new stuff: finished most of the importing routines, extended the database (single table inheritance) and expanded some other stuff.

This commit is contained in:
James Cole
2014-07-05 19:44:26 +02:00
parent a0c0dc288d
commit 188105492c
26 changed files with 430 additions and 587 deletions

14
app/models/Budget.php Normal file
View File

@@ -0,0 +1,14 @@
<?php
/**
* Created by PhpStorm.
* User: sander
* Date: 05/07/14
* Time: 18:24
*/
class Budget extends Component {
protected $isSubclass = true;
}

6
app/models/Category.php Normal file
View File

@@ -0,0 +1,6 @@
<?php
class Category extends Component
{
protected $isSubclass = true;
}

View File

@@ -1,8 +1,12 @@
<?php
class Component extends Elegant
class Component extends Firefly\Database\SingleTableInheritanceEntity
{
protected $table = 'components';
protected $subclassField = 'class';
public static $rules
= [
'user_id' => 'exists:users,id|required',
@@ -11,15 +15,14 @@ class Component extends Elegant
];
public function componentType()
{
return $this->belongsTo('ComponentType');
}
public function transactions()
{
return $this->belongsToMany('Transaction');
}
public function transactionjournals()
{
return $this->belongsToMany('TransactionJournal');
}
public function user()
{

View File

@@ -1,11 +0,0 @@
<?php
class ComponentType extends Eloquent
{
public function components()
{
return $this->hasMany('Component');
}
}

View File

@@ -26,4 +26,13 @@ class Transaction extends Elegant
{
return $this->belongsToMany('Component');
}
public function budgets()
{
return $this->belongsToMany('Budget');
}
public function categories()
{
return $this->belongsToMany('Category');
}
}

View File

@@ -28,6 +28,21 @@ class TransactionJournal extends Elegant
return $this->hasMany('Transaction');
}
public function components()
{
return $this->belongsToMany('Component');
}
public function budgets()
{
return $this->belongsToMany('Budget','component_transaction_journal','transaction_journal_id','component_id');
}
public function categories()
{
return $this->belongsToMany('Category','component_transaction_journal','transaction_journal_id','component_id');
}
public function getDates()
{
return array('created_at', 'updated_at', 'date');