芝麻web文件管理V1.00
编辑当前文件:/home/sditechnicalteam/public_html/app/Models/Product.php
environment(['development','demo']) && str_contains($this->default_image, 'http')) { return $this->default_image; } return ($this->default_image) ? asset_url_local_s3(Product::FILE_PATH . '/' . $this->default_image) : ''; } public function getDownloadFileUrlAttribute() { return ($this->downloadable_file) ? asset_url_local_s3(Product::FILE_PATH . '/' . $this->downloadable_file) : null; } public function tax(): BelongsTo { return $this->belongsTo(Tax::class)->withTrashed(); } public static function taxbyid($id) { return Tax::where('id', $id)->withTrashed(); } public function category(): BelongsTo { return $this->belongsTo(ProductCategory::class, 'category_id'); } public function subCategory(): BelongsTo { return $this->belongsTo(ProductSubCategory::class, 'sub_category_id'); } public function getTotalAmountAttribute() { if (!is_null($this->price) && !is_null($this->tax)) { return (int)$this->price + ((int)$this->price * ((int)$this->tax->rate_percent / 100)); } return ''; } public function files(): HasMany { return $this->hasMany(ProductFiles::class, 'product_id')->orderBy('id', 'desc'); } public function getTaxListAttribute() { $productItem = Product::findOrFail($this->id); $taxes = ''; if ($productItem && $productItem->taxes) { $numItems = count(json_decode($productItem->taxes)); if (!is_null($productItem->taxes)) { foreach (json_decode($productItem->taxes) as $index => $tax) { $tax = $this->taxbyid($tax)->first(); $taxes .= $tax->tax_name . ': ' . $tax->rate_percent . '%'; $taxes = ($index + 1 != $numItems) ? $taxes . ', ' : $taxes; } } } return $taxes; } }