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

26 lines
624 B
PHP
Raw Permalink Normal View History

2013-10-27 01:06:58 +02:00
<?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;
}
}