<?php namespace App\Http\Controllers; use App\Models\{Intern,InternLearningItem,InternEvaluation,InternCertificate}; use Illuminate\Http\Request; class InternDevelopmentController extends Controller {public function show(Intern $intern){return view('interns.development',compact('intern'));}public function learning(Request $r,Intern $intern){$d=$r->validate(['title'=>'required|string|max:180','description'=>'nullable|string','due_date'=>'nullable|date']);$intern->learningItems()->create($d);return back()->with('success','Learning item added.');}public function evaluate(Request $r,Intern $intern){$d=$r->validate(['evaluation_type'=>'required|string|max:40','evaluation_date'=>'required|date','technical_score'=>'required|integer|min:0|max:100','communication_score'=>'required|integer|min:0|max:100','attendance_score'=>'required|integer|min:0|max:100','ownership_score'=>'required|integer|min:0|max:100','strengths'=>'nullable|string','improvements'=>'nullable|string','recommendation'=>'nullable|string|max:120']);$d['evaluator_user_id']=$r->user()->id;$intern->evaluations()->create($d);return back()->with('success','Evaluation recorded.');}public function certificate(Request $r,Intern $intern){abort_if($intern->certificate,422,'Certificate already issued.');$intern->certificate()->create(['certificate_no'=>'SST-INT-'.now()->format('Y').'-'.str_pad($intern->id,5,'0',STR_PAD_LEFT),'issued_on'=>today(),'issued_by'=>$r->user()->id,'status'=>'issued']);$intern->update(['status'=>'completed']);return back()->with('success','Internship completed and certificate issued.');}}