You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.1 KiB
35 lines
1.1 KiB
5 years ago
|
<?php
|
||
|
namespace App;
|
||
|
|
||
|
use Illuminate\Database\Eloquent\Model;
|
||
|
|
||
|
class CooperationData extends Model
|
||
|
{
|
||
|
// protected $table = 'cooperation_data';
|
||
|
protected $table = 'data_cooperation';
|
||
|
public $fillable = ['type_id','type','data' , 'model_type'];
|
||
|
|
||
|
public function getDataAttribute()
|
||
|
{
|
||
|
return json_decode($this->attributes['data']);
|
||
|
}
|
||
|
|
||
|
public function setDataAttribute($value)
|
||
|
{
|
||
|
$this->attributes['data'] = json_encode($value, JSON_UNESCAPED_UNICODE);
|
||
|
}
|
||
|
public static function getFormData($model_id,$model_type){
|
||
|
$coop = CooperationData::where('model_type' , $model_type)->where('type_id' , $model_id);
|
||
|
if ($coop->get()){
|
||
|
return $coop->get();
|
||
|
}return [];
|
||
|
}
|
||
|
public static function lgn($value){
|
||
|
$ex = explode ('Common_',$value);
|
||
|
if (count ($ex) > 1){
|
||
|
return trans ("validation.attributes.{$ex[1]}");
|
||
|
}
|
||
|
return trans ("validation.attributes.{$value}");
|
||
|
}
|
||
|
}
|