我有一个具有管理员和用户帐户的应用程序(例如护士,医生)e.t.c.如果护士预约某位医生,我希望医生在使用laravel登录他的账户时,在医生仪表板上显示所有预约的清单。我不知道如何去做,护士和医生都有不同的仪表板。
约会数据库包含doctor_id,patient_id和appointment_date,如下所示
<form method="POST" action="{{url('Others/Operator/Appointment/book_appointment')}}">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="row">
<div class="form-group {{ $errors->has('patient_id') ? ' has-error' : '' }}">
<label for="lastname" class="col-md-3 control-label">Select a Patient</label>
<select class="form-control" name="patient_id" >
<option value="">Select </option>
@if(isset($patients))
@foreach($patients as $pat)
<option value="{{$pat->id}} @if (request('pat') == $pat->name) selected='selected' @endif ">{{$pat->tag_name}}-{{$pat->name}} </option>
@endforeach
@endif
</select>
@if ($errors->has('patient_id'))
<span class="help-block">
<strong>{{ $errors->first('patient_id') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group {{ $errors->has('patient_id') ? ' has-error' : '' }}">
<br>
<label for="lastname" class="col-md-3 control-label">Select a Doctor</label>
<table id="example" class="table table-striped table-bordered" cellspacing="0" width="100%">
<thead >
<tr >
{{--<th>--}}
{{--S/N--}}
{{--</th>--}}
<th>
Picture
</th>
<th style="text-align: center;">
Name
</th>
<th style="text-align: center;">
Specialization
</th>
<th style="text-align: center;">
Phone Number
</th>
<th style="text-align: center;">
Status
</th>
<th style="text-align: center;">
Book
</th>
{{--<th style="text-align: center;">--}}
{{--Message--}}
{{--</th>--}}
</tr>
</thead>
<tbody>
<?php $c=0;?>
@foreach($doctors as $dr)
<tr style="padding: 10px; text-align: center;">
{{--<td>{{++$c}}</td>--}}
<td>
<img src='{{url("assets/images/doctors_pic_uploads/".$dr->pic)}}' style="height:40px; width:40px;" class="img-circle">
</td>
<td style="padding: 20px;">{{$dr->name}}</td>
<td style="padding: 20px; ">{{$dr->specialization}}</td>
<td style="padding: 20px;">{{$dr->phone}}</td>
<td style="padding: 20px;" >
{{--{{$dr->user->active_user}}--}}
<span class=" alert-{{(\App\User::find($dr->user_id)->active_user==1?'success':'danger')}} lg ">{{(\App\User::find($dr->user_id)->active_user==1?"Online":"Offline")}}</span>
</td>
<td style="padding: 20px;" class="{{ $errors->has('appointment_date') ? ' has-error' : '' }}">
<input type="radio" name="doctor_id" value="{{$dr->id}}">
{{--<a href="#" data-toggle="modal" data-target="#myModal{{$dr->id}}" class=" btn-warning ">Book</a>--}}
{{--<a href="{{url('admin/Doctors/delete/doctor/'.$pat->id.'')}}" class="btn btn-danger xs">Delete</a>--}}
</td>
{{--<td><a href="" class="btn btn-success xs">Message</a></td>--}}
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="row">
<div class="form-group {{ $errors->has('appointment_date') ? ' has-error' : '' }}">
<label for="lastname" class="col-md-2 control-label">Birth Date</label>
<input type="date" class="form-control" name="appointment_date" value="{{date('d-m-Y')}}{{Request::old('date') }}" placeholder="Birth Date" >
@if ($errors->has('appointment_date'))
<span class="help-block">
<strong>{{ $errors->first('appointment_date') }}</strong>
</span>
@endif
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<button type="submit" class="btn btn-primary">Book a Doctor</button>
</div>
</div>
</div>
</form>
它运作正常但我不知道如何收集具体的医生ID并将约会信息放在他的仪表板上,所以一旦他登录他就会看到它
答案 0 :(得分:0)
您可以在模特身上使用 where 。
前:
$appointments = Appointment::where('doctor_id', '=', $loginedDoctorID)->get();
您将获得 doctor_id 的所有约会。
见这里:https://laravel.com/docs/5.2/eloquent#retrieving-multiple-models