<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Facades\Storage;

class College extends Model
{
    use HasFactory;

    protected $fillable = [
        'name',
        'logo_path',
        'city_state',
    ];

    public function students(): HasMany
    {
        return $this->hasMany(Student::class);
    }

    public function getLogoUrlAttribute(): ?string
    {
        return $this->logo_path ? Storage::url($this->logo_path) : null;
    }
}
