<?php

namespace App\Models;

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

class Occupation extends Model{
    use HasFactory;
    protected $table = 'occupation';
    
    protected $fillable = [
        'occupation_title',
        'status',
        'deleted_at',
        'created_at',
        'updated_at'
    ];

    public function export($slug){
        $collection = DB::table('occupation')
                        ->select('occupation_title', 'created_at');

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