<?php

use App\Models\Introductif;
use App\Models\ReportQuarter;
use Livewire\Component;

new class extends Component
{
    public $data = null;
    public $school;
    public $cutting;

    public function __contruct($cutting, $school) {
        $this->cutting = $cutting;
        $this->school = $school;
    }

    public function mount() {
        $report = ReportQuarter::where('school_id', $this->school)->where('cutting_school_year_id', $this->cutting)->first();
        $text = $report ? Introductif::where('report_quarter_id', $report->id)->first():null;

        $paragraphs = explode("\n", $text ? $text->content:null);
        $paragraphs = array_map(function ($p) {
            return ucfirst(trim($p));
        }, $paragraphs);
        $this->data = implode("\n", $paragraphs);
    }

};
?>

<div>
    <div class="head" style="text-align:center; padding-top: 250px">
        <h2 style="text-decoration: underline; font-weight: bold;">INTRODUCTION </h2>
    </div>
    <div class="content" style="margin-top: 35px; font-size: 15px">
        {!! nl2br(e(ucfirst($data))) !!}
    </div>
</div>