vendredi 21 août 2020

laravel two table value compare , and show value in foreach

laravel compare two table value and show the value in foreach. my code showing error help me to solve this.

i am comparing "delete_status" in both model if "supplier" model delete_status is "NOT_DELETED" it compere titem_list model "delete_status" values if "NOT_DELETED" it will showed items in foreach other showed dont show item.

my controller

public function  totalproduct()
{
    $totalproductlist = DB::table('item_lists')->join('suppliers', 'item_lists.delete_status', '!=', 'suppliers.delete_status')->where('suppliers.delete_status','=','DELETED')->get();
    return view('products.total-product',compact('totalproductlist'));        

}

my model ( Item_list )

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Item_list extends Model
{
     protected $table = 'item_lists';
     protected $fillable = ['product_name','qty','purchase_rate','MRP_rate','sale_rate','supplier_name','part_no'];

}

my model ( Supplier )

<?php

namespace App;
use App\Purchase;
use Illuminate\Database\Eloquent\Model;

class Supplier extends Model
{
     protected $table = 'suppliers';
     protected $fillable = ['party_id','suppliers_master_id','suppliers_unic_id','supplier_name','email','phone','address','city','state','pincode','GSTIN','delete_status','BILL_TYPE'];

    public function items()
    {
        return $this->hasMany(Item_list::class, 'supplier_name', 'supplier_name');
    }
}


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire