Update models to have more relationships and timestamp column definitions.

This commit is contained in:
Taylor Dondich
2019-04-25 14:15:41 -07:00
committed by Paula Quispe
parent 9aec728509
commit 426c2f6f39
5 changed files with 34 additions and 2 deletions

View File

@@ -7,4 +7,23 @@ use Illuminate\Database\Eloquent\Model;
class Application extends Model
{
protected $table = "APPLICATION";
// Our custom timestamp columns
const CREATED_AT = 'APP_CREATE_DATE';
const UPDATED_AT = 'APP_UPDATE_DATE';
public function delegations()
{
return $this->hasMany(Delegation::class, 'APP_UID', 'APP_UID');
}
public function parent()
{
return $this->hasOne(Application::class, 'APP_PARENT', 'APP_UID');
}
public function currentUser()
{
return $this->hasOne(User::class, 'APP_CUR_USER', 'USR_UID');
}
}

View File

@@ -8,6 +8,9 @@ class Delegation extends Model
{
protected $table = "APP_DELEGATION";
// We don't have our standard timestamp columns
protected $timestamps = false;
/**
* Returns the application this delegation belongs to
*/

View File

@@ -14,9 +14,9 @@ class Process extends Model
{
// Set our table name
protected $table = 'PROCESS';
// We do have a created at, but we don't store an updated at
// Our custom timestamp columns
const CREATED_AT = 'PRO_CREATE_DATE';
const UPDATED_AT = null;
const UPDATED_AT = 'PRO_UPDATE_DATE';
/**
* Retrieve all applications that belong to this process
@@ -26,4 +26,9 @@ class Process extends Model
return $this->hasMany(Application::class, 'PRO_ID', 'PRO_ID');
}
public function creator()
{
return $this->hasOne(User::class, 'PRO_CREATE_USER', 'USR_UID');
}
}

View File

@@ -7,6 +7,8 @@ use Illuminate\Database\Eloquent\Model;
class Task extends Model
{
protected $table = 'TASK';
// We do not have create/update timestamps for this table
protected $timestamps = false;
public function process()
{

View File

@@ -7,6 +7,9 @@ use Illuminate\Database\Eloquent\Model;
class User extends Model
{
protected $table = "USERS";
// Our custom timestamp columns
const CREATED_AT = 'USR_CREATE_DATE';
const UPDATED_AT = 'USR_UPDATE_DATE';
/**
* Returns the delegations this user has (all of them)