Last active
September 11, 2017 12:19
-
-
Save 3h5a9/22be6d671ba30488797a58e0c431b97e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @extends('layouts.app') | |
| @section('title', 'Create a New Student') | |
| @section('stylesheet') | |
| <style> | |
| .panel-primary { margin-bottom: 80px; } | |
| .tab-pane { padding: 20px 0px; } | |
| </style> | |
| <link rel="stylesheet" href="{{ asset('css/bootstrap-datetimepicker.min.css') }}"> | |
| @stop | |
| @section('content') | |
| <div class="container"> | |
| <div class="row"> | |
| <div class="col-md-10 col-md-offset-1"> | |
| @if ( Session::has('success') ) | |
| <div class="alert alert-success"> | |
| <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> | |
| <strong>Success!</strong> {{ Session::get('success') }} | |
| </div> | |
| @endif | |
| </div> | |
| </div> | |
| <div class="row"> | |
| <div class="col-md-10 col-md-offset-1"> | |
| <div class="panel panel-primary"> | |
| <div class="panel-heading">Edit <strong>{{$student->fullname}}'s</strong> information</div> | |
| {!! Form::model([ $student, ['route' => ['home.student.update', $student->id], 'method' => 'patch']]) !!} | |
| <div class="panel-body"> | |
| <div role="tabpanel"> | |
| <!-- Nav tabs --> | |
| <ul class="nav nav-tabs" role="tablist"> | |
| <li role="presentation" class="active"> | |
| <a href="#home" aria-controls="home" role="tab" data-toggle="tab">home</a> | |
| </li> | |
| <li role="presentation"> | |
| <a href="#contact" aria-controls="tab" role="tab" data-toggle="tab">Contact Information</a> | |
| </li> | |
| <li role="presentation"> | |
| <a href="#other" aria-controls="tab" role="tab" data-toggle="tab">Other Information</a> | |
| </li> | |
| </ul> | |
| <!-- Tab panes --> | |
| <div class="tab-content"> | |
| <div role="tabpanel" class="tab-pane active" id="home"> | |
| <div class="form-group col-md-4"> | |
| {{ Form::label( 'fname', 'Student First Name: ') }} | |
| {{ Form::text('fname', null, ['class' => 'form-control', 'placeholder' => 'Student First Name']) }} | |
| </div> | |
| <div class="form-group col-md-4"> | |
| {{ Form::label( 'mname', 'Student Middle Name: ') }} | |
| {{Form::text('mname', null, ['class' => 'form-control', 'placeholder' => 'Student Middle Name']) }} | |
| </div> | |
| <div class="form-group col-md-4"> | |
| {{ Form::label( 'lname', 'Student Last Name: ') }} | |
| {{Form::text('lname', null, ['class' => 'form-control', 'placeholder' => 'Student Last Name']) }} | |
| </div> | |
| <div class="form-group col-md-4"> | |
| {{ Form::label( 'dob', 'Student Date of Birth: ') }} | |
| {{ Form::text('dob', null, ['class' => 'form-control', 'id' => 'datetimepicker4', 'placeholder' => 'DD/MM/YYYY']) }} | |
| </div> | |
| <div class="form-group col-md-4"> | |
| {{ Form::label('gender', 'Gender') }} | |
| {{ Form::select('gender', ['Male' => 'Male', 'Female' => 'Female'], null, ['class' => 'form-control' , 'placeholder' => 'Pick a Gender...']) }} | |
| </div> | |
| <div class="form-group col-md-4"> | |
| {{ Form::label('bloodgroup', 'Blood Group') }} | |
| {{ Form::select('bloodgroup', | |
| [ | |
| 'A+' => 'A+', | |
| 'A-' => 'A-', | |
| 'B+' => 'B+', | |
| 'B-' => 'B-', | |
| 'O+' => 'O+', | |
| 'O-' => 'O-', | |
| 'AB+' => 'AB+', | |
| 'AB-' => 'AB-', | |
| ], | |
| null, ['class' => 'form-control' , 'placeholder' => 'Please Select...']) }} | |
| </div> | |
| <div class="form-group col-md-4"> | |
| {{ Form::label( 'bplace', 'Student Birth Place: ') }} | |
| {{ Form::text('bplace', null, ['class' => 'form-control', 'placeholder' => 'Birth Place']) }} | |
| </div> | |
| <div class="form-group col-md-4"> | |
| {{ Form::label('nationality', 'Student Nationality') }} | |
| {{ Form::select('nationality', | |
| [ | |
| 'Bangladeshi' => 'Bangladeshi', | |
| 'Others' => 'Others' | |
| ], | |
| null, ['class' => 'form-control' , 'placeholder' => 'Please Select Country...']) }} | |
| </div> | |
| <div class="form-group col-md-4"> | |
| {{ Form::label('religion', 'Student Religion') }} | |
| {{ Form::select('religion', | |
| [ | |
| 'Islam' => 'Islam', | |
| 'Others' => 'Others' | |
| ], | |
| null, ['class' => 'form-control' , 'placeholder' => 'Please Select Religion...']) }} | |
| </div> | |
| </div> | |
| <div role="tabpanel" class="tab-pane fade" id="contact"> | |
| <div class="form-group col-md-6"> | |
| {{ Form::label('presentadd', 'Present Address') }} | |
| {{ Form::textarea('presentadd', null, ['class' => 'form-control', 'rows' => '3', 'placeholder' => 'Present Address']) }} | |
| </div> | |
| <div class="form-group col-md-6"> | |
| {{ Form::label('permanentadd', 'Permanent Address') }} | |
| {{ Form::textarea('permanentadd', null, ['class' => 'form-control', 'rows' => '3', 'placeholder' => 'Permanent Address']) }} | |
| </div> | |
| <div class="form-group col-md-4"> | |
| {{ Form::label( 'city', 'City: ') }} | |
| {{ Form::text('city', null, ['class' => 'form-control', 'placeholder' => 'City']) }} | |
| </div> | |
| <div class="form-group col-md-4"> | |
| {{ Form::label( 'ps', 'Police Station: ') }} | |
| {{Form::text('ps', null, ['class' => 'form-control', 'placeholder' => 'Police Station']) }} | |
| </div> | |
| <div class="form-group col-md-4"> | |
| {{ Form::label( 'zipcode', 'Zip Code: ') }} | |
| {{Form::text('zipcode', null, ['class' => 'form-control', 'placeholder' => 'Zip Code']) }} | |
| </div> | |
| <div class="form-group col-md-4"> | |
| {{ Form::label( 'phone', 'Phone Number: ') }} | |
| {{ Form::text('phone', null, ['class' => 'form-control', 'placeholder' => 'Phone Number']) }} | |
| </div> | |
| <div class="form-group col-md-4"> | |
| {{ Form::label( 'mobile', 'Mobile Number: ') }} | |
| {{Form::text('mobile', null, ['class' => 'form-control', 'placeholder' => 'Mobile Number']) }} | |
| </div> | |
| <div class="form-group col-md-4"> | |
| {{ Form::label( 'email', 'e-mail Address: ') }} | |
| {{Form::email('email', null, ['class' => 'form-control', 'placeholder' => 'example@example.com']) }} | |
| </div> | |
| </div> | |
| <div role="tabpanel" class="tab-pane fade" id="other"> | |
| <div class="form-group col-md-4"> | |
| {{ Form::label( 'roll', 'Roll Number: ') }} | |
| {{ Form::text('roll', null, ['class' => 'form-control', 'placeholder' => 'Roll Number']) }} | |
| </div> | |
| <div class="form-group col-md-4"> | |
| {{ Form::label('class', 'Class:') }} | |
| {{ Form::select('class', | |
| [ | |
| 'iii' => 'iii (class 3)', | |
| 'iv' => 'iv (class 4)', | |
| 'v' => 'v (class 5)', | |
| 'vi' => 'vi (class 6)', | |
| 'vii' => 'vii (class 6)', | |
| 'viii' => 'viii (class 8)', | |
| 'ix' => 'ix (class 9)', | |
| 'x' => 'x (class 10)', | |
| 'xi' => 'xi (class 11)', | |
| 'xii' => 'xii (class 12)' | |
| ], | |
| null, ['class' => 'form-control' , 'placeholder' => 'Please Select Class...']) }} | |
| </div> | |
| <div class="form-group col-md-4"> | |
| {{ Form::label('section', 'Section:') }} | |
| {{ Form::select('section', | |
| [ | |
| 'A' => 'A', | |
| 'B' => 'B', | |
| 'C' => 'C', | |
| 'D' => 'D' | |
| ], | |
| null, ['class' => 'form-control' , 'placeholder' => 'Please Select Section...']) }} | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="panel-footer"> | |
| <div class="row text-center"> | |
| <div class="col-md-12"> | |
| {{ Form::submit('Update Information', ['class' => 'btn btn-success btn-sm']) }} | |
| {{ Html::linkRoute('home.student.show', 'Cancle Update', array($student->id), array('class' => 'btn btn-danger btn-sm') ) }} | |
| </div> | |
| </div> | |
| </div> | |
| {!! Form::close() !!} | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| @endsection | |
| @section('scripts') | |
| <script type="text/javascript"> | |
| $(function () { | |
| $('#datetimepicker4').datetimepicker({ | |
| format: 'DD/MM/YYYY', | |
| icons: { | |
| time: 'ion-ios-clock', | |
| date: 'ion-ios-calendar', | |
| up: 'ion-chevron-up', | |
| down: 'ion-chevron-down', | |
| previous: 'ion-chevron-left', | |
| next: 'ion-chevron-right', | |
| today: 'ion-ionic', | |
| clear: 'ion-ios-trash', | |
| close: 'ion-android-remove-circle' | |
| } | |
| }); | |
| }); | |
| </script> | |
| <script src="{{ asset('js/moment.js') }}"></script> | |
| <script src="{{ asset('js/bootstrap-datetimepicker.js') }}"></script> | |
| @endsection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App\Http\Controllers; | |
| use Illuminate\Http\Request; | |
| use App\Http\Requests; | |
| use App\Student; | |
| Use DB; | |
| class StudentController extends Controller | |
| { | |
| public function __construct() | |
| { | |
| $this->middleware('auth'); | |
| } | |
| /** | |
| * Display a listing of the resource. | |
| * | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function index() | |
| { | |
| //Show All | |
| $students = Student::all(); | |
| return view('pages.students', compact('students') ); | |
| } | |
| /** | |
| * Show the form for creating a new resource. | |
| * | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function create() | |
| { | |
| return view('pages.create'); | |
| } | |
| /** | |
| * Store a newly created resource in storage. | |
| * | |
| * @param \Illuminate\Http\Request $request | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function store(Request $request) | |
| { | |
| //Validate | |
| $this->validate($request, array( | |
| 'fname' => 'required|max:255', | |
| 'mname' => 'required', | |
| 'lname' => 'required', | |
| 'dob' => 'required', | |
| 'gender' => 'required', | |
| 'bloodgroup' => 'required', | |
| 'bplace' => 'required', | |
| 'nationality' => 'required', | |
| 'religion' => 'required', | |
| 'presentadd' => 'required', | |
| 'permanentadd' => 'required', | |
| 'city' => 'required', | |
| 'ps' => 'required', | |
| 'zipcode' => 'required', | |
| 'phone' => 'required', | |
| 'mobile' => 'required', | |
| 'email' => 'required|unique:students,email', | |
| 'roll' => 'required|unique:students,roll', | |
| 'class' => 'required', | |
| 'section' => 'required' | |
| )); | |
| // Store | |
| $student = new Student; | |
| $student->fname = $request->fname; | |
| $student->mname = $request->mname; | |
| $student->lname = $request->lname; | |
| $student->dob = $request->dob; | |
| $student->gender = $request->gender; | |
| $student->bloodgroup = $request->bloodgroup; | |
| $student->bplace = $request->bplace; | |
| $student->nationality = $request->nationality; | |
| $student->religion = $request->religion; | |
| $student->presentadd = $request->presentadd; | |
| $student->permanentadd = $request->permanentadd; | |
| $student->city = $request->city; | |
| $student->ps = $request->ps; | |
| $student->zipcode = $request->zipcode; | |
| $student->phone = $request->phone; | |
| $student->mobile = $request->mobile; | |
| $student->email = $request->email; | |
| $student->roll = $request->roll; | |
| $student->class = $request->class; | |
| $student->section = $request->section; | |
| $student->save(); | |
| // Redirect | |
| return redirect()->route('home.student.index'); | |
| } | |
| /** | |
| * Display the specified resource. | |
| * | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function show($id) | |
| { | |
| $student = Student::find($id); | |
| return view('pages.show', compact('student') ); | |
| } | |
| /** | |
| * Show the form for editing the specified resource. | |
| * | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function edit($id) | |
| { | |
| $student = Student::find($id); | |
| return view('pages.edit', compact('student') ); | |
| } | |
| /** | |
| * Update the specified resource in storage. | |
| * | |
| * @param \Illuminate\Http\Request $request | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function update(Request $request, $id) | |
| { | |
| //Validate | |
| $this->validate($request, array( | |
| 'fname' => 'required|max:255', | |
| 'mname' => 'required', | |
| 'lname' => 'required', | |
| 'dob' => 'required', | |
| 'gender' => 'required', | |
| 'bloodgroup' => 'required', | |
| 'bplace' => 'required', | |
| 'nationality' => 'required', | |
| 'religion' => 'required', | |
| 'presentadd' => 'required', | |
| 'permanentadd' => 'required', | |
| 'city' => 'required', | |
| 'ps' => 'required', | |
| 'zipcode' => 'required', | |
| 'phone' => 'required', | |
| 'mobile' => 'required', | |
| 'email' => 'required|unique:students,email', | |
| 'roll' => 'required|unique:students,roll', | |
| 'class' => 'required', | |
| 'section' => 'required' | |
| )); | |
| // Save data to database | |
| $student = Student::find($id); | |
| $student->fname = $request->input('fname'); | |
| $student->mname = $request->input('mname'); | |
| $student->lname = $request->input('lname'); | |
| $student->dob = $request->input('dob'); | |
| $student->gender = $request->input('gender'); | |
| $student->bloodgroup = $request->input('bloodgroup'); | |
| $student->bplace = $request->input('bplace'); | |
| $student->nationality = $request->input('nationality'); | |
| $student->religion = $request->input('religion'); | |
| $student->presentadd = $request->input('presentadd'); | |
| $student->permanentadd = $request->input('permanentadd'); | |
| $student->city = $request->input('city'); | |
| $student->ps = $request->input('ps'); | |
| $student->zipcode = $request->input('zipcode'); | |
| $student->phone = $request->input('phone'); | |
| $student->mobile = $request->input('mobile'); | |
| $student->email = $request->input('email'); | |
| $student->roll = $request->input('roll'); | |
| $student->class = $request->input('class'); | |
| $student->section = $request->input('section'); | |
| $student->save(); | |
| // Redirect | |
| return redirect()->route('home.student.index', $post->id); | |
| } | |
| /** | |
| * Remove the specified resource from storage. | |
| * | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function destroy($id) | |
| { | |
| // | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment