update api for manager
This commit is contained in:
@ -5,7 +5,6 @@ namespace common\models;
|
||||
use Yii;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\Expression;
|
||||
use yii\helpers\ArrayHelper;
|
||||
|
||||
/**
|
||||
* This is the model class for table "template".
|
||||
@ -14,12 +13,14 @@ use yii\helpers\ArrayHelper;
|
||||
* @property string $title
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
* @property string $template_file_name
|
||||
*
|
||||
* @property Document[] $documents
|
||||
* @property TemplateDocumentField[] $templateDocumentFields
|
||||
*/
|
||||
class Template extends \yii\db\ActiveRecord
|
||||
{
|
||||
public $template;
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -47,7 +48,12 @@ class Template extends \yii\db\ActiveRecord
|
||||
{
|
||||
return [
|
||||
[['created_at', 'updated_at'], 'safe'],
|
||||
[['title'], 'string', 'max' => 255],
|
||||
[['title'], 'unique'],
|
||||
[['template_file_name', 'title'], 'required'],
|
||||
[['template'], 'required', 'message'=>'Укажите путь к файлу'],
|
||||
[['template'], 'file', 'maxSize' => '10000'],
|
||||
[['template'], 'file', 'skipOnEmpty' => false, 'extensions' => 'doc, docx, txt'],
|
||||
[['title', 'template_file_name'], 'string', 'max' => 255],
|
||||
];
|
||||
}
|
||||
|
||||
@ -61,6 +67,7 @@ class Template extends \yii\db\ActiveRecord
|
||||
'title' => 'Название',
|
||||
'created_at' => 'Дата создания',
|
||||
'updated_at' => 'Дата изменения',
|
||||
'template_file_name' => 'Файл шаблона',
|
||||
];
|
||||
}
|
||||
|
||||
@ -69,6 +76,14 @@ class Template extends \yii\db\ActiveRecord
|
||||
foreach ($this->templateDocumentFields as $templateDocumentField){
|
||||
$templateDocumentField->delete();
|
||||
}
|
||||
|
||||
if (!empty($this->template_file_name)) {
|
||||
$template_path = Yii::getAlias('@templates') . '/' . $this->template_file_name;
|
||||
|
||||
if(file_exists($template_path)) {
|
||||
unlink($template_path);
|
||||
}
|
||||
}
|
||||
return parent::beforeDelete();
|
||||
}
|
||||
|
||||
|
@ -225,6 +225,11 @@ class UserCard extends \yii\db\ActiveRecord
|
||||
return $this->hasOne(Manager::class, ['user_card_id' => 'id']);
|
||||
}
|
||||
|
||||
public function getManagerEmployee()
|
||||
{
|
||||
return $this->hasMany(ManagerEmployee::class, ['user_card_id' => 'id']);
|
||||
}
|
||||
|
||||
public static function generateUserForUserCard($card_id = null)
|
||||
{
|
||||
$userCardQuery = self::find();
|
||||
|
Reference in New Issue
Block a user