This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
Sequenzia/app/models/UserRecord.php
2013-10-26 18:06:58 -05:00

26 lines
624 B
PHP
Executable File

<?php
class UserRecord extends Rails\ActiveRecord\Base
{
protected function associations()
{
return [
'belongs_to' => [
'user',
'reporter' => ['foreign_key' => "reported_by", 'class_name' => "User"]
]
];
}
protected function validations()
{
return [
'user_id' => ['presence' => true],
'reported_by' => ['presence' => true]
];
}
protected function setUser($name)
{
$this->user_id = ($user = User::where(['name' => $name])->first()) ? $user->id : null;
}
}