<?php

namespace App\Models;

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

class OtherOne extends Model{
    use HasFactory;
    protected $table = 'other_one';
    
    protected $fillable = [
        'name',
        'status',
        'created_at',
        'updated_at',
        'created_by',
        'updated_by',
    ];

     public function export($slug){
        $collection = DB::table('other_one')
                        ->select('name', 'status');

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


    
}
