✏️ Edit: Products.php
Path:
/home/thiqat5/dex.thiqatech.com/model/Products.php
Size: 1.91 KB · Modified: 2021-11-03 20:28:12 · Perm: 0644 · Writable
← Back to directory
👁 View
⬇ Download
<?php namespace App\model; use Illuminate\Database\Eloquent\Model; class Products extends Model { protected $table = 'products'; protected $hidden = []; protected $appends = ['ProdcutsComments', 'ProdcutsUnit','ShopName','ShopId', 'ShopCityId']; public function getProdcutsUnitAttribute() { $Units = Unit:: where('id', $this->unit)-> get(); return $Units; } public function getProdcutsCommentsAttribute() { $Productcomments = Productcomment:: where('Shop_Id', $this->id)-> get(); return $Productcomments; } public function Shops() { // return $this->belongsToMany('\Products', 'ordersprpductlists'); return $this->hasOne('App\model\Shop', 'id', 'shop'); } public function getShopNameAttribute() { //return $this->shop; $shopId = $this->shop ; $Shop = Shop ::where('id', $shopId)->first(); if ( $Shop == null ) return 'shop'; else return $Shop->name ; } public function getShopIdAttribute() { //return $this->shop; $shopId = $this->shop ; $Shop = Shop ::where('id', $shopId)->first(); if ( $Shop == null ) return 'shop'; else return $Shop->id ; } public function getShopIdAttribute() { //return $this->shop; $shopId = $this->shop ; $Shop = Shop ::where('id', $shopId)->first(); if ( $Shop == null ) return '0'; else return $Shop->id ; } public function getShopCityIdAttribute() { //return $this->shop; $shopId = $this->shop ; $Shop = Shop ::where('id', $shopId)->first(); if ( $Shop == null ) return 'shop'; else return $Shop->city ; } }
💾 Save
Cancel
Save as UTF-8, newlines normalized to LF