MOON
Server: Apache
System: Linux e2e-78-16.ssdcloudindia.net 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64
User: imensosw (1005)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/imensosw/public_html/amanda/app/Product.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Product extends Model
{
    use SoftDeletes;

    protected $fillable = [
        'name', 'price', 'units', 'description', 'image','type','status','category_id','fileType'
    ];

    public function orders(){
        return $this->hasMany(Order::class);
    }

    public static function checkProductExistAlongCategoryId($id)
    {
    	$result = Product::where('products.category_id',$id)->count();
    	if($result>0){

    	return 1;
    	}
    	else{
    		return 0;
    	}
    }

    public static function checkProductExistAlongTagId($id)
    {
    	// $result = \DB::table('product_tag')->where('product_tag.tag_id',$id)->count();
    	$result = Product::leftjoin('product_tag','product_tag.product_id','products.id')
    			->where('product_tag.tag_id',$id)->count();
    	if($result>0){
    		return 1;
    	}
    	else{
    		return 0;
    	}
    }
}