<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use DB;

class Fasttag extends Model{
    use HasFactory;
    protected $table = 'fasttags';
    
    protected $fillable = [
        'brand_name',
        'amount',
        'profit',
        'gst_percentage',
        'gst',
        'total_profit',
        'status',
        'created_by',
        'created_at',
        'updated_by',
        'updated_at'
    ];

    public function export($slug){
        $collection = DB::table('fasttags')
                        ->select('brand_name', 'amount', 'profit', 'gst_percentage', 'gst', 'total_profit', 'status');

        if($slug != 'all')
            $collection->where(['status' => $slug]);
        
        $data = $collection->get();
        
        if($data->isNotEmpty()){
            return $data;
        }else{
            return null;
        }
    }
}
