<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\Internship;
class Category extends Model
{
//table name
protected $table = 'categories';
protected $primaryKey = 'id';
//get internships count of each category
//return counts
public function getInternshipCount()
{
return Internship::where('deadline', '>=', \DB::raw('now()'))
->where('category_id', '=', $this->id)
->count();
}
}