codigo actual del servidor, con avances de joan

This commit is contained in:
Jose Sanchez
2023-08-07 15:52:04 -04:00
commit 3cd9b8bbe8
3070 changed files with 532255 additions and 0 deletions

26
app/Models/Attribute.php Normal file
View File

@@ -0,0 +1,26 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App;
class Attribute extends Model
{
protected $with = ['attribute_translations'];
public function getTranslation($field = '', $lang = false){
$lang = $lang == false ? App::getLocale() : $lang;
$attribute_translation = $this->attribute_translations->where('lang', $lang)->first();
return $attribute_translation != null ? $attribute_translation->$field : $this->$field;
}
public function attribute_translations(){
return $this->hasMany(AttributeTranslation::class);
}
public function attribute_values() {
return $this->hasMany(AttributeValue::class);
}
}