Update models to have more relationships and timestamp column definitions.
This commit is contained in:
committed by
Paula Quispe
parent
9aec728509
commit
426c2f6f39
@@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user