@extends('layouts.teacher')

@section('content')

<!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
	  <div class="container-full">
		<!-- Content Header (Page header) -->
		<div class="content-header">
			<div class="d-flex align-items-center">
				<div class="me-auto">
					<h3 class="page-title">Edit Home Work</h3>
					<div class="d-inline-block align-items-center">
						<nav>
							<ol class="breadcrumb">
								<li class="breadcrumb-item"><a href="{{ route('teacher.index') }}"><i class="mdi mdi-home-outline"></i></a></li>
								<li class="breadcrumb-item" aria-current="page">Home Work</li>
								<li class="breadcrumb-item active" aria-current="page">Edit</li>
							</ol>
						</nav>
					</div>
				</div>
				
			</div>
		</div>	  

		<!-- Main content -->
		<section class="content">
			<div class="row">			  
				
				<div class="col-lg-12 col-12">
					
					@if ($errors->any())
                        <div class="alert alert-danger">
                            <strong>Whoops!</strong> There were some problems with your input.<br><br>
                            <ul>
                                @foreach ($errors->all() as $error)
                                    <li>{{ $error }}</li>
                                @endforeach
                            </ul>
                        </div>
                    @endif
					  <div class="box">
						<!-- /.box-header -->
						<form class="form" action="{{ route('teacher.home.work.update') }}" method="post">
							@csrf
							<input type="hidden" name="homework_id" value="{{ $homework->id }}">
							<div class="box-body">
								<div class="row">
									<div class="col-md-6">
										<div class="col-md-12">
											<div class="form-group">
												<label class="form-label">Select Student</label>
												<div class="input-group mb-3">
													<select class="form-control @error('student') is-invalid @enderror select2" name="student">
														<option value="">Select Student</option>
														@if(count($students) > 0)
														@foreach($students as $key => $value)
														<option value="{{ $value->id }}" @if( $value->id == $homework->student_id) selected @endif>{{ $value->name }}</option>
														@endforeach
														@endif
													</select>
												</div>
												@error('student')
				                                    <span class="invalid-feedback" role="alert">
				                                        <strong>{{ $message }}</strong>
				                                    </span>
				                                @enderror
											</div>
										</div>
										<div class="col-md-12">
											<div class="form-group">
												<label class="form-label">Homework Title</label>
												<div class="input-group mb-3">
													<input type="text" class="form-control @error('homework_title') is-invalid @enderror" name="homework_title" placeholder="Homework Title" value="{{ $homework->homework_title }}" required>
												</div>
												@error('homework_title')
				                                    <span class="invalid-feedback" role="alert">
				                                        <strong>{{ $message }}</strong>
				                                    </span>
				                                @enderror
											</div>
										</div>
										<div class="col-md-12">
											<div class="form-group">
												<label class="form-label">Homework LastDate</label>
												<div class="input-group mb-3">
													<input type="date" onfocus="'showPicker' in this && this.showPicker()" class="form-control @error('homework_last_date') is-invalid @enderror" name="homework_last_date" value="{{ $homework->homework_last_date }}">
												</div>
												@error('homework_last_date')
				                                    <span class="invalid-feedback" role="alert">
				                                        <strong>{{ $message }}</strong>
				                                    </span>
				                                @enderror
											</div>
										</div>
										<div class="col-md-12">
											<div class="form-group">
												<label class="form-label">Homework Description</label>
												<textarea class="form-control" name="homework_description" rows="5">
														 {{ $homework->homework_description }}
												</textarea>
												@error('homework_description')
				                                    <span class="invalid-feedback" role="alert">
				                                        <strong>{{ $message }}</strong>
				                                    </span>
				                                @enderror
											</div>
										</div>
										
									</div>
									<div class="col-md-6">
										
									</div>
								</div>								
								
							</div>
							<!-- /.box-body -->
							<div class="box-footer text-end">
								<input type="submit" name="submit" class="btn btn-primary" value="Submit">
								<!-- <button type="submit" class="btn btn-primary">
								  <i class="ti-save-alt"></i> Save
								</button> -->
							</div>  
						</form>
					  </div>
					  <!-- /.box -->			
				</div>

		    </div>
			
		  </div>
		  <!-- /.row -->

		</section>
		<!-- /.content -->
	  </div>
  </div>
  <!-- /.content-wrapper -->

@endsection