<?php

namespace App\Models;

use App\Models\Concerns\NormalizesEmails;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;

class CoursewarePartner extends Model
{
    use NormalizesEmails;

    protected $fillable = [
        'user_id',
        'authorised_partner_id',
        'courseware_category_id',
        'applicant_name',
        'designation',
        'building',
        'street',
        'city',
        'state',
        'postal_code',
        'country',
        'email',
        'phone',
        'photo_path',
        'id_proof_path',
        'institute_name',
        'official_building',
        'official_street',
        'official_city',
        'official_state',
        'official_postal_code',
        'official_country',
        'official_email',
        'official_phone',
        'website',
        'second_contact_name',
        'second_contact_email',
        'second_contact_phone',
        'mobile',
        'practical_lab_area',
        'theory_classroom_area',
        'requirements',
    ];

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }

    public function category(): BelongsTo
    {
        return $this->belongsTo(CoursewareCategory::class, 'courseware_category_id');
    }

    public function authorisedPartner(): BelongsTo
    {
        return $this->belongsTo(AuthorisedPartner::class);
    }

    public function superAdmins(): BelongsToMany
    {
        return $this->belongsToMany(User::class, 'courseware_partner_user');
    }
}
