Nuevos cambios hechos de diseño
This commit is contained in:
21
desarrollo2/app/Models/Role.php
Normal file
21
desarrollo2/app/Models/Role.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App;
|
||||
|
||||
class Role extends Model
|
||||
{
|
||||
protected $with = ['role_translations'];
|
||||
|
||||
public function getTranslation($field = '', $lang = false){
|
||||
$lang = $lang == false ? App::getLocale() : $lang;
|
||||
$role_translation = $this->role_translations->where('lang', $lang)->first();
|
||||
return $role_translation != null ? $role_translation->$field : $this->$field;
|
||||
}
|
||||
|
||||
public function role_translations(){
|
||||
return $this->hasMany(RoleTranslation::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user