23.11 Upload to live
This commit is contained in:
parent
8cae2f92a4
commit
8ebdacec98
80 changed files with 7320 additions and 3937 deletions
75
app/Models/IqSite.php
Normal file
75
app/Models/IqSite.php
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
|
||||
class IqSite extends Model
|
||||
{
|
||||
|
||||
protected $table = 'iq_sites';
|
||||
|
||||
protected $casts = ['products' => 'array', 'set_products' => 'array'];
|
||||
|
||||
protected $fillable = [
|
||||
'slug', 'headline', 'copy', 'products', 'set_products',
|
||||
];
|
||||
|
||||
public function iq_image()
|
||||
{
|
||||
return $this->belongsTo('App\Models\IqImage', 'iq_image_id');
|
||||
}
|
||||
|
||||
|
||||
public function getLang($key)
|
||||
{
|
||||
$lang = \App::getLocale();
|
||||
if ($lang == 'de') {
|
||||
return $this->{$key};
|
||||
}
|
||||
$trans = $this->getTrans($key, $lang);
|
||||
if (!$trans || $trans == '') {
|
||||
return $this->{$key};
|
||||
}
|
||||
return $trans;
|
||||
}
|
||||
|
||||
public function getTrans($key, $lang)
|
||||
{
|
||||
$key = 'trans_' . $key;
|
||||
if (!empty($this->{$key}[$lang])) {
|
||||
return $this->{$key}[$lang];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
public function getProductModels(){
|
||||
$ret = [];
|
||||
foreach($this->products as $product_id){
|
||||
$ret[] = Product::findOrFail($product_id);
|
||||
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getProductSetModels(){
|
||||
$ret = [];
|
||||
foreach($this->set_products as $product_id){
|
||||
$ret[] = Product::findOrFail($product_id);
|
||||
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function hasImage(){
|
||||
if($this->iq_image_id){
|
||||
if($this->iq_image && isset($this->iq_image->slug) && $this->iq_image->active){
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue