Попытка перенести данные, введенные в одну форму, в новую форму для отдельного действия. - PullRequest
0 голосов
/ 26 февраля 2020

Я работаю над моим последним проектом года, системой управления планированием операций, я уже создал форму запроса для запроса операции, которую необходимо забронировать, записи в этой форме затем отображаются в виде списка ожидания. В идеале я хотел бы иметь возможность щелкнуть одну из записей данных в списке ожидания, чтобы иметь возможность «создать бронирование», при нажатии на запись в списке ожидания она должна перейти к другой форме, аналогичной форме запроса на операцию. , но с данными, уже введенными в поле, в этой форме я затем хочу иметь возможность отправить их, а затем просмотреть отправленные заказы в виде «забронированных операций», мне было интересно, есть ли у кого-нибудь какие-либо предложения относительно моего лучшего способа go об этом, не влияя на записи в списке ожидания.

Ниже приведен код для моего представления формы запроса на операцию:

'''
@extends('layouts.app')
@section('content')
<h1>Surgery Request Form</h1>
{!! Form::open(['url' => 'requestform/submit']) !!}

    <div class="form-group">
    {{Form::label('requestID', 'Request ID')}}
    {{Form::number('requestID', 'Request ID', ['class' => 'form-control',])}}
    </div>

    <div class="form-group">
    {{Form::label('requestDate', 'Request Date')}}
    {{Form::date('requestDate', \Carbon\Carbon::now(), ['class' => 'form-control'])}}
    </div>

    <div class="form-group">
    {{Form::label('patientID', 'Patient ID')}}
    {{Form::number('patientID', 'Patient ID', ['class' => 'form-control'])}}
    </div>

    <div class="form-group">
    {{Form::label('patientForename', 'Patient Forename')}}
    {{Form::text('patientForename', 'Patient Forename', ['class' => 'form-control'])}}
    </div>

    <div class="form-group">
    {{Form::label('patientSurname', 'Patient Surname')}}
    {{Form::text('patientSurname', 'Patient Surname', ['class' => 'form-control',])}}
    </div>

    <div class="form-group">
    {{Form::label('patientSex', 'Patient Sex')}}
    {{Form::select('patientSex', ['Male' => 'Male', 'Female' => 'Female'], null, ['class' => 'form-control', 'placeholder' => ''])}}
    </div>

    <div class="form-group">
    {{Form::label('patientDOB', 'Patient DOB')}}
    {{Form::date('patientDOB')}}
    </div>

    <div class="form-group">
    {{Form::label('surgeryType', 'Surgery Type')}}
    {{Form::select('surgeryType', ['Appendectomy' => 'Appendectomy', 'Myringotomy' => 'Myringotomy', 'Tonsillectomy' => 'Tonsillectomy', 'Hysteroscopy' => 'Hysteroscopy', 'Cystoscopy' => 'Cystoscopy',
    'Hysterectomy' => 'Hysterectomy', 'Cholecystectomy' => 'Cholecystectomy'], null, ['class' => 'form-control','placeholder' => ''])}}
    </div>

    <div class="form-group">
    {{Form::label('patientUrgency', 'Patient Urgency')}}
    {{Form::select('patientUrgency', ['Routine' => 'Routine', 'Urgent' => 'Urgent', 'Red-Flag' => 'Red-Flag'], null, ['class' => 'form-control','placeholder' => ''])}}
    </div>

    <div class="form-group">
    {{Form::label('bloodGroup', 'Blood Group')}}
    {{Form::select('bloodGroup', ['A' => 'A', 'B' => 'B', 'O' => 'O', 'AB' => 'AB'], null, ['class' => 'form-control','placeholder' => ''])}}
    </div>

    <div>
      {{Form::submit('Submit Request', ['class'=> 'btn btn-primary'])}}
    </div>
{!! Form::close() !!}
@endsection

'' '

Ниже приведен код контроллера для форма запроса на операцию:

        <?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\RequestForm;

class RequestFormsController extends Controller
{
    public function submit(Request $request){
      $this->validate($request, [
        'requestID' => 'required',
        'requestDate' => 'required',
        'patientID' => 'required',
        'patientForename' => 'required',
        'patientSurname'=> 'required',
        'patientSex' => 'required',
        'patientDOB' => 'required',
        'surgeryType' => 'required',
        'patientUrgency' => 'required',
        'bloodGroup' => 'required'
      ]);


      // Create new Request Form
      $requestForm = new RequestForm;
      $requestForm->requestID = $request->input('requestID');
      $requestForm->requestDate = $request->input('requestDate');
      $requestForm->patientID = $request->input('patientID');
      $requestForm->patientForename = $request->input('patientForename');
      $requestForm->patientSurname = $request->input('patientSurname');
      $requestForm->patientSex = $request->input('patientSex');
      $requestForm->patientDOB = $request->input('patientDOB');
      $requestForm->surgeryType = $request->input('surgeryType');
      $requestForm->patientUrgency = $request->input('patientUrgency');
      $requestForm->bloodGroup = $request->input('bloodGroup');

      //Save Request form

      $requestForm->save();

      //redirect

      return redirect('/')->with('success', 'Request Submitted');
    }

return redirect('/')->with('success', 'Request Submitted');

public function submitBooking(Booking $Booking){
      $this->validate($booking, [
        'requestID' => 'required',
        'requestDate' => 'required',
        'patientID' => 'required',
        'bookingID' => 'required',
        'patientForename' => 'required',
        'patientSurname'=> 'required',
        'patientSex' => 'required',
        'patientDOB' => 'required',
        'surgeryDate' => 'required',
        'surgeryType' => 'required',
        'theatreRoomID' => 'required',
        'patientUrgency' => 'required',
        'patientNotes' => 'required',
        'bloodGroup' => 'required'
      ]);


      // Create new Request Form
      $bookingForm = new bookingForm;
      $bookingForm->requestID = $booking->input('requestID');
      $bookingForm->requestDate = $booking->input('requestDate');
      $bookingForm->bookingID = $booking->input('bookingID');
      $bookingForm->patientID = $booking->input('patientID');
      $bookingForm->patientForename = $booking->input('patientForename');
      $bookingForm->patientSurname = $booking->input('patientSurname');
      $bookingForm->patientSex = $booking->input('patientSex');
      $bookingForm->patientDOB = $booking->input('patientDOB');
      $bookingForm->surgeryType = $booking->input('surgeryType');
      $bookingForm->surgeryDate = $booking->input('surgeryDate');
      $bookingForm->patientUrgency = $booking->input('patientUrgency');
      $bookingForm->patientNotes = $booking->input('patientNotes');
      $bookingForm->bloodGroup = $booking->input('bloodGroup');

      //Save Booking form

      $bookingForm->save();

      //redirect
      return redirect('/')->with('success', 'Booking Submitted');

    public function getWaitingLists(){
      $waitinglists = RequestForm::all();

      return view('waitinglist')->with('waitinglist', $waitinglists);
    }

    public function getPatientData(Request $request,$id){
 $patientDetail = RequestForm::where('patientID',$id)->first();

 return view('bookingFormView')->with('patientDetail', $patientDetail);
}


}

А ниже приведен код просмотра списка ожидания:

     @extends('layouts.app')
@section('content')
<h1>Waiting List</h1>
@if(count($waitinglist) > 0)
  @foreach($waitinglist as $requestForm)
  <a href="http://localhost:8000/bookingForm/show/{{$requestForm->patientID}}"><td>{{$requestForm->patientID}}</td></a>
    <table class="table">
  <thead class="thead-dark">
    <tr>
      <th scope="col">#</th>
      <th scope="col">Request ID</th>

      <th scope="col">Request Date</th>
      <th scope="col">Patient ID</th>
      <th scope="col">Patient Forename</th>
      <th scope="col">Patient Surname</th>
      <th scope="col">Patient Sex</th>
      <th scope="col">Patient DOB</th>
      <th scope="col">Surgery Type</th>
      <th scope="col">Patient Urgeny</th>
      <th scope="col">Blood Group</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row"></th>
      <td>{{$requestForm->requestID}}</td>
      <td>{{$requestForm->requestDate}}</td>
      <td>{{$requestForm->patientID}}</td>
      <td>{{$requestForm->patientForename}}</td>
      <td>{{$requestForm->patientSurname}}</td>
      <td>{{$requestForm->patientSex}}</td>
      <td>{{$requestForm->patientDOB}}</td>
      <td>{{$requestForm->surgeryType}}</td>
      <td>{{$requestForm->patientUrgency}}</td>
      <td>{{$requestForm->bloodGroup}}</</td>
    </tr>
  </tbody>
</table>
  @endforeach
@endif
@endsection

@section('sidebar')
@parent
<p>This is appended to the Sidebar</p>
@endsection

Маршруты (веб. * 1035) *)

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/requestform', 'PagesController@getRequestForm');

Route::get('/waitinglist', 'RequestFormsController@getWaitingLists');


Route::post('/requestform/submit', 'RequestFormsController@submit');

Route::get('/bookingForm/show/{patientID}', 'RequestFormsController@getPatientData' )->name('update.request');


Route::get('/', 'PagesController@getHome');

Route::get('/about', 'PagesController@getAbout');

Route::get('/contact', 'PagesController@getContact');

Route::get('/welcome', 'PagesController@getWelcome');

Route::get('/login', 'LoginController@getLogin');

Route::get('/messages', 'MessagesController@getMessages');

Route::post('/contact/submit', 'MessagesController@submit');

Route::get('/register', 'RegisterController@getRegister');

Route::get('/logout', 'LoginController@logout');

Route::get('/logout', '\App\Http\Controllers\Auth\LoginController@logout');


Auth::routes();
Route::get('/', 'PagesController@getHome');
Route::get('/home', 'HomeController@index');

  Route::prefix('admin')->group(function() {
    Route::get('/login', 'Auth\AdminLoginController@showLoginForm')->name('admin.login');
    Route::post('/login', 'Auth\AdminLoginController@login')->name('admin.login.submit');
    Route::get('/', 'AdminController@index')->name('admin.dashboard');
  });

Маршруты (PagesController)

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class PagesController extends Controller
{
    public function getHome(){
      return view('home');
    }

    public function getAbout(){
      return view('about');
    }

    public function getContact(){
      return view('Contact');
    }

    public function getLogin(){
      return view('login');
    }

    public function getWelcome(){
      return view('welcome');
    }

    public function getRegister(){
      return view('register');
    }

    public function getAdmin(){
      return view('admin');
    }

    public function getRequestForm(){
      return view('requestForm');
    }

    public function getPatientData(){
      return view('bookingForm');
    }






}

Просмотр формы бронирования:

    @extends('layouts.app')
@section('content')
<h1>Booking Form</h1>
{!! Form::open(['url' => 'bookingform/submit']) !!}

    <div class="form-group">
    {{Form::label('requestID', 'Request ID')}}
    {{Form::number('requestID', $patientDetail->requestID, ['class' => 'form-control',])}}
    </div>

    <div class="form-group">
    {{Form::label('requestDate', 'Request Date')}}
    {{Form::date('requestDate', $patientDetail->requestDate, ['class' => 'form-control'])}}
    </div>

    <div class="form-group">
    {{Form::label('patientID', 'Patient ID')}}
    {{Form::number('patientID', $patientDetail->patientID, ['class' => 'form-control'])}}
    </div>

    <div class="form-group">
    {{Form::label('patientForename', 'Patient Forename')}}
    {{Form::text('patientForename', $patientDetail->patientForename, ['class' => 'form-control'])}}
    </div>

    <div class="form-group">
    {{Form::label('patientSurname', 'Patient Surname')}}
    {{Form::text('patientSurname', $patientDetail->patientSurname, ['class' => 'form-control',])}}
    </div>

    <div class="form-group">
    {{Form::label('patientSex', 'Patient Sex')}}
    {{Form::label('patientSex', $patientDetail->patientSex, ['class' => 'form-control', 'placeholder' => ''])}}
    </div>

    <div class="form-group">
    {{Form::label('patientDOB', 'Patient DOB')}}
    {{Form::label('patientDOB', $patientDetail->patientDOB, ['class' => 'form-control','placeholder' => ''])}}
    </div>

    <div class="form-group">
    {{Form::label('surgeryType', 'Surgery Type')}}
    {{Form::label('surgeryType', $patientDetail->surgeryType, ['class' => 'form-control','placeholder' => ''])}}
    </div>

    <div class="form-group">
    {{Form::label('patientUrgency', 'Patient Urgency')}}
    {{Form::label('patientUrgency', $patientDetail->patientUrgency, ['class' => 'form-control','placeholder' => ''])}}
    </div>

    <div class="form-group">
    {{Form::label('bloodGroup', 'Blood Group')}}
    {{Form::label('bloodGroup', $patientDetail->bloodGroup,  ['class' => 'form-control', 'placeholder' => ''])}}
    </div>

    <div>
      {{Form::submit('Submit Booking', ['class'=> 'btn btn-primary'])}}
    </div>
{!! Form::close() !!}
@endsection

Любая помощь для этого очень ценится.

1 Ответ

0 голосов
/ 26 февраля 2020

вы можете дать ссылку href с идентификатором RequestForm и написать функцию, которая возвращает целые данные текущего идентификатора RequestForm и передает данные в представление ваших забронированных операций и передает данные в качестве значения по умолчанию в {{Form::text('patientSurname', 'Patient Surname'}}, который вы можете добавить это, по вашему мнению, где вы показываете пациента, просто оберните его с помощью тега привязки:

@extends('layouts.app')
  @section('content')
 <h1>Waiting List</h1>
 @if(count($waitinglist) > 0)
  @foreach($waitinglist as $requestForm)
   <table class="table">
    <thead class="thead-dark">
    <tr>
     <th scope="col">#</th>
     <th scope="col">Request ID</th>

  <th scope="col">Request Date</th>
  <th scope="col">Patient ID</th>
  <th scope="col">Patient Forename</th>
  <th scope="col">Patient Surname</th>
  <th scope="col">Patient Sex</th>
  <th scope="col">Patient DOB</th>
  <th scope="col">Surgery Type</th>
  <th scope="col">Patient Urgeny</th>
  <th scope="col">Blood Group</th>
</tr>
 </thead>
 <tbody>
<tr>
  <th scope="row"></th>
  <td><a href={{ url('/bookingForm/show/'.$requestForm->patientID) }}>{{$requestForm->patientID}}</a></td>
  <td>{{$requestForm->requestDate}}</td>
  <td>{{$requestForm->patientID}}</td>
  <td>{{$requestForm->patientForename}}</td>
  <td>{{$requestForm->patientSurname}}</td>
  <td>{{$requestForm->patientSex}}</td>
  <td>{{$requestForm->patientDOB}}</td>
  <td>{{$requestForm->surgeryType}}</td>
  <td>{{$requestForm->patientUrgency}}</td>
  <td>{{$requestForm->bloodGroup}}</</td>
</tr>
</tbody>
 </table>
 @endforeach
 @endif
 @endsection

@section('sidebar')
@parent
 <p>This is appended to the Sidebar</p>
@endsection

, если вы хотите узнать больше о теге привязки нажмите здесь и затем в вашем контроллере вы можете напишите функцию:

  public function getPatientData(Request $request,$id){
  $patientDetail = RequestForm::where('patientID',$id)->first();

  return view('bookingFormView')->with('patientDetail', $patientDetail);
}

и, наконец, вы получите данные в bookingFormView, прикрепите их к форме в качестве значения по умолчанию для элемента, и вы готовы к go

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...