403Webshell
Server IP : 66.29.132.124  /  Your IP : 3.137.221.114
Web Server : LiteSpeed
System : Linux business141.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : wavevlvu ( 1524)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/wavevlvu/book24.ng/modules/Core/Models/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/wavevlvu/book24.ng/modules/Core/Models/Attributes.php
<?php
namespace Modules\Core\Models;

use App\BaseModel;
use Illuminate\Database\Eloquent\SoftDeletes;

class Attributes extends BaseModel
{
    use SoftDeletes;
    protected $table = 'bravo_attrs';
    protected $fillable = ['name','display_type','hide_in_single','hide_in_filter_search','position'];
    protected $slugField = 'slug';
    protected $slugFromField = 'name';

    public function terms()
    {
        return $this->hasMany(Terms::class, 'attr_id', 'id')->with(['translations']);
    }

    public function fill(array $attributes)
    {
        if(!empty($attributes)){
            foreach ( $this->fillable as $item ){
                $attributes[$item] = $attributes[$item] ?? null;
            }
        }
        return parent::fill($attributes); // TODO: Change the autogenerated stub
    }

    public static function getAllAttributesForApi($service_type){
        $data = [];
        $attributes = Attributes::selectRaw("id,name,slug,service")->where('service', $service_type)->get();
        foreach ($attributes as $item){
            $translation = $item->translateOrOrigin(app()->getLocale());
            $list_terms = $item->terms;
            $data[] = [
                'id'    => $item->id,
                'name'  => $translation->name,
                'slug'  => $item->slug,
                'terms' => $list_terms->map(function ($term) {
                    return $term->dataForApi();
                })
            ];
        }
        return $data;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit