[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: Product.php
<?php namespace App; use Illuminate\Database\Eloquent\Model; class Product extends Model { /** * The attributes that aren't mass assignable. * * @var array */ protected $guarded = ['id']; protected $appends = ['image_url']; /** * The attributes that should be cast to native types. * * @var array */ protected $casts = [ 'sub_unit_ids' => 'array', ]; /** * Get the products image. * * @return string */ public function getImageUrlAttribute() { if (! empty($this->image)) { $image_url = asset('/uploads/img/'.rawurlencode($this->image)); } else { $image_url = asset('/img/default.png'); } return $image_url; } /** * Get the products image path. * * @return string */ public function getImagePathAttribute() { if (! empty($this->image)) { $image_path = public_path('uploads').'/'.config('constants.product_img_path').'/'.$this->image; } else { $image_path = null; } return $image_path; } public function product_variations() { return $this->hasMany(\App\ProductVariation::class); } /** * Get the brand associated with the product. */ public function brand() { return $this->belongsTo(\App\Brands::class); } /** * Get the unit associated with the product. */ public function unit() { return $this->belongsTo(\App\Unit::class); } /** * Get the unit associated with the product. */ public function second_unit() { return $this->belongsTo(\App\Unit::class, 'secondary_unit_id'); } /** * Get category associated with the product. */ public function category() { return $this->belongsTo(\App\Category::class); } /** * Get sub-category associated with the product. */ public function sub_category() { return $this->belongsTo(\App\Category::class, 'sub_category_id', 'id'); } /** * Get the tax associated with the product. */ public function product_tax() { return $this->belongsTo(\App\TaxRate::class, 'tax', 'id'); } /** * Get the variations associated with the product. */ public function variations() { return $this->hasMany(\App\Variation::class); } /** * If product type is modifier get products associated with it. */ public function modifier_products() { return $this->belongsToMany(\App\Product::class, 'res_product_modifier_sets', 'modifier_set_id', 'product_id'); } /** * If product type is modifier get products associated with it. */ public function modifier_sets() { return $this->belongsToMany(\App\Product::class, 'res_product_modifier_sets', 'product_id', 'modifier_set_id'); } /** * Get the purchases associated with the product. */ public function purchase_lines() { return $this->hasMany(\App\PurchaseLine::class); } /** * Scope a query to only include active products. * * @param \Illuminate\Database\Eloquent\Builder $query * @return \Illuminate\Database\Eloquent\Builder */ public function scopeActive($query) { return $query->where('products.is_inactive', 0); } /** * Scope a query to only include inactive products. * * @param \Illuminate\Database\Eloquent\Builder $query * @return \Illuminate\Database\Eloquent\Builder */ public function scopeInactive($query) { return $query->where('products.is_inactive', 1); } /** * Scope a query to only include products for sales. * * @param \Illuminate\Database\Eloquent\Builder $query * @return \Illuminate\Database\Eloquent\Builder */ public function scopeProductForSales($query) { return $query->where('not_for_selling', 0); } /** * Scope a query to only include products not for sales. * * @param \Illuminate\Database\Eloquent\Builder $query * @return \Illuminate\Database\Eloquent\Builder */ public function scopeProductNotForSales($query) { return $query->where('not_for_selling', 1); } public function product_locations() { return $this->belongsToMany(\App\BusinessLocation::class, 'product_locations', 'product_id', 'location_id'); } /** * Scope a query to only include products available for a location. * * @param \Illuminate\Database\Eloquent\Builder $query * @return \Illuminate\Database\Eloquent\Builder */ public function scopeForLocation($query, $location_id) { return $query->where(function ($q) use ($location_id) { $q->whereHas('product_locations', function ($query) use ($location_id) { $query->where('product_locations.location_id', $location_id); }); }); } /** * Get warranty associated with the product. */ public function warranty() { return $this->belongsTo(\App\Warranty::class); } public function media() { return $this->morphMany(\App\Media::class, 'model'); } public function rack_details() { return $this->hasMany(\App\ProductRack::class); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.86 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285