Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mohammadkhallaf's avatar

make profile for patient

in this blade i wont to make a profile for every patient how can i display the information for own patient that come form all models

@extends('layouts.master')
@section('title')
patient profile
@endsection
@section('css')

@endsection
@section('title_page1')

@endsection
@section('title_page2')

@endsection
@section('content')
<section class="content">
    <div class="container-fluid">
      <div class="row">
        <div class="col-md-3">

          <!-- Profile Image -->

          <!-- /.card -->

          <!-- About Me Box -->
          <div class="card card-primary">
            <div class="card-header">
              <h3 class="card-title">About patient </h3>
            </div>
            <!-- /.card-header -->
            <div class="card-body">
              <strong><i class="fas fa-book mr-1"></i> name</strong>

              <p class="text-muted">
               {{$customers->name}}
              </p>

              <hr>

              <strong><i class="fas fa-map-marker-alt mr-1"></i> address</strong>

              <p class="text-muted"> {{$customers->address}}</p>

              <hr>

              <strong><i class="fas fa-pencil-alt mr-1"></i> national id</strong>

              <p class="text-muted">
                <span class="tag tag-danger">{{$customers->personal_id}}</span>

              </p>

              <hr>

              <strong><i class="far fa-file-alt mr-1"></i> mobile</strong>

              <p class="text-muted">{{$customers->phone}}</p>
              <hr>

              <strong><i class="far fa-file-alt mr-1"></i> gender</strong>

              <p class="text-muted">{{$customers->gender}}</p>
            </div>
            <!-- /.card-body -->
          </div>
          <!-- /.card -->
        </div>
        <!-- /.col -->
        <div class="col-md-9">
          <div class="card">
            <div class="card-header p-2">
              <ul class="nav nav-pills">
                <li class="nav-item"><a class="nav-link active" href="#activity" data-toggle="tab">tests</a></li>
                <li class="nav-item"><a class="nav-link" href="#timeline" data-toggle="tab">Timeline</a></li>
                <li class="nav-item"><a class="nav-link" href="#settings" data-toggle="tab">Settings</a></li>
              </ul>
            </div><!-- /.card-header -->
            <div class="card-body">
              <div class="tab-content">
                <div class="tab-pane active" id="activity">
                  <!-- Post -->

                  <!-- /.post -->

                  <!-- Post -->
                  <table id="example1" class="table table-bordered table-striped" dir="rtl">
                    <thead>
                        <tr>
                            <th>#</th>

                            <th> test id </th>
                            <th>distance</th>
                            <th> right_eye_without_corr </th>
                            <th>left_eye_without_corr</th>
                            <th> right_eye_with_corr </th>
                            <th>left_eye_with_corr</th>
                            <th>date</th>
                            <th>report </th>
                            <th>cost </th>
                             <th>attach </th>
                            <th>actions</th>

                        </tr>
                    </thead>
                    <tbody>
                        @foreach ($customers as $key => $customer)
                        <tr>

                            <td>{{$customer->$ptests }}</td>
                            <td></td>
                            <td>

                            </td>
                        </tr>
                        @endforeach
                    </tbody>
                </table>
                  <!-- /.post -->
                </div>
                <!-- /.tab-pane -->
                <div class="tab-pane" id="timeline">
                  <!-- The timeline -->
                  <div class="timeline timeline-inverse">
                    <!-- timeline time label -->
                    <div class="time-label">
                      <span class="bg-danger">
                        10 Feb. 2014
                      </span>
                    </div>
                    <!-- /.timeline-label -->
                    <!-- timeline item -->
                    <div>
                      <i class="fas fa-envelope bg-primary"></i>

                      <div class="timeline-item">
                        <span class="time"><i class="far fa-clock"></i> 12:05</span>

                        <h3 class="timeline-header"><a href="#">Support Team</a> sent you an email</h3>

                        <div class="timeline-body">
                          Etsy doostang zoodles disqus groupon greplin oooj voxy zoodles,
                          weebly ning heekya handango imeem plugg dopplr jibjab, movity
                          jajah plickers sifteo edmodo ifttt zimbra. Babblely odeo kaboodle
                          quora plaxo ideeli hulu weebly balihoo...
                        </div>
                        <div class="timeline-footer">
                          <a href="#" class="btn btn-primary btn-sm">Read more</a>
                          <a href="#" class="btn btn-danger btn-sm">Delete</a>
                        </div>
                      </div>
                    </div>
                    <!-- END timeline item -->
                    <!-- timeline item -->
                    <div>
                      <i class="fas fa-user bg-info"></i>

                      <div class="timeline-item">
                        <span class="time"><i class="far fa-clock"></i> 5 mins ago</span>

                        <h3 class="timeline-header border-0"><a href="#">Sarah Young</a> accepted your friend request
                        </h3>
                      </div>
                    </div>
                    <!-- END timeline item -->
                    <!-- timeline item -->
                    <div>
                      <i class="fas fa-comments bg-warning"></i>

                      <div class="timeline-item">
                        <span class="time"><i class="far fa-clock"></i> 27 mins ago</span>

                        <h3 class="timeline-header"><a href="#">Jay White</a> commented on your post</h3>

                        <div class="timeline-body">
                          Take me to your leader!
                          Switzerland is small and neutral!
                          We are more like Germany, ambitious and misunderstood!
                        </div>
                        <div class="timeline-footer">
                          <a href="#" class="btn btn-warning btn-flat btn-sm">View comment</a>
                        </div>
                      </div>
                    </div>
                    <!-- END timeline item -->
                    <!-- timeline time label -->
                    <div class="time-label">
                      <span class="bg-success">
                        3 Jan. 2014
                      </span>
                    </div>
                    <!-- /.timeline-label -->
                    <!-- timeline item -->
                    <div>
                      <i class="fas fa-camera bg-purple"></i>

                      <div class="timeline-item">
                        <span class="time"><i class="far fa-clock"></i> 2 days ago</span>

                        <h3 class="timeline-header"><a href="#">Mina Lee</a> uploaded new photos</h3>

                        <div class="timeline-body">
                          <img src="https://placehold.it/150x100" alt="...">
                          <img src="https://placehold.it/150x100" alt="...">
                          <img src="https://placehold.it/150x100" alt="...">
                          <img src="https://placehold.it/150x100" alt="...">
                        </div>
                      </div>
                    </div>
                    <!-- END timeline item -->
                    <div>
                      <i class="far fa-clock bg-gray"></i>
                    </div>
                  </div>
                </div>
                <!-- /.tab-pane -->

                <div class="tab-pane" id="settings">
                  <form class="form-horizontal">
                    <div class="form-group row">
                      <label for="inputName" class="col-sm-2 col-form-label">Name</label>
                      <div class="col-sm-10">
                        <input type="email" class="form-control" id="inputName" placeholder="Name">
                      </div>
                    </div>
                    <div class="form-group row">
                      <label for="inputEmail" class="col-sm-2 col-form-label">Email</label>
                      <div class="col-sm-10">
                        <input type="email" class="form-control" id="inputEmail" placeholder="Email">
                      </div>
                    </div>
                    <div class="form-group row">
                      <label for="inputName2" class="col-sm-2 col-form-label">Name</label>
                      <div class="col-sm-10">
                        <input type="text" class="form-control" id="inputName2" placeholder="Name">
                      </div>
                    </div>
                    <div class="form-group row">
                      <label for="inputExperience" class="col-sm-2 col-form-label">Experience</label>
                      <div class="col-sm-10">
                        <textarea class="form-control" id="inputExperience" placeholder="Experience"></textarea>
                      </div>
                    </div>
                    <div class="form-group row">
                      <label for="inputSkills" class="col-sm-2 col-form-label">Skills</label>
                      <div class="col-sm-10">
                        <input type="text" class="form-control" id="inputSkills" placeholder="Skills">
                      </div>
                    </div>
                    <div class="form-group row">
                      <div class="offset-sm-2 col-sm-10">
                        <div class="checkbox">
                          <label>
                            <input type="checkbox"> I agree to the <a href="#">terms and conditions</a>
                          </label>
                        </div>
                      </div>
                    </div>
                    <div class="form-group row">
                      <div class="offset-sm-2 col-sm-10">
                        <button type="submit" class="btn btn-danger">Submit</button>
                      </div>
                    </div>
                  </form>
                </div>
                <!-- /.tab-pane -->
              </div>
              <!-- /.tab-content -->
            </div><!-- /.card-body -->
          </div>
          <!-- /.card -->
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
    </div><!-- /.container-fluid -->
  </section>
@endsection






@section('scripts')

@endsection

this is controller

public function show(Customer $customer,$id)
    {
        $customers = Customer::find($id);
        $appointment = Appointment::find($id);
        $finances = Finance::find($id);
        $ptests = PersonalTest::find($id);
        $tests = Test::find($id);
        return view('admin.customer.profile', compact('appointment', 'finances', 'ptests', 'tests','customers'));
    }
0 likes
33 replies
Tray2's avatar

I would eager load the releated data.

public function show(Customer $customer,$id)
    {
        $customer = Customer::with('appointments', 'finances', 'personal_tests', 'tests')->find($id);
        return view('admin.customer.profile', compact('customers');
    }

Then you can access it as

$customer->appointments
mohammadkhallaf's avatar

@Tray2

how to use it in the blade
<table id="example1" class="table table-bordered table-striped" dir="rtl">
                    <thead>
                        <tr>


                            <th> test id </th>
                            <th>distance</th>
                            <th> right_eye_without_corr </th>
                            <th>left_eye_without_corr</th>
                            <th> right_eye_with_corr </th>
                            <th>left_eye_with_corr</th>
                            <th>date</th>



                        </tr>
                    </thead>
                    <tbody>
                        @foreach ($customers as  $customer)
                        <tr>

                            <td>{{$customer->personaltests->test_id }}</td>
                            {{-- <td>{{$ptests->distance }}</td>
                            <td>{{$ptests->right_eye_without_corr }}</td>
                            <td>{{$ptests->left_eye_without_corr }}</td>
                            <td>{{$ptests->right_eye_with_corr }}</td>
                            <td>{{$ptests->left_eye_with_corr }}</td>
                            <td>{{$ptests->date}}</td> --}}

                        </tr>
                        @endforeach
                    </tbody>
                </table>
mohammadkhallaf's avatar

@Tray2 when use this the table looks empty but i have an data in the database

 <table id="example1" class="table table-bordered table-striped" dir="rtl">
                    <thead>
                        <tr>


                            <th> test id </th>
                            <th>distance</th>
                            <th> right_eye_without_corr </th>
                            <th>left_eye_without_corr</th>
                            <th> right_eye_with_corr </th>
                            <th>left_eye_with_corr</th>
                            <th>date</th>



                        </tr>
                    </thead>
                    <tbody>
                        @foreach ($customers as  $customer)
                        <tr>

                            <td>{{$customers->test_id}}</td>
                            <td>{{$customers->distance }}</td>
                            <td>{{$customers->right_eye_without_corr }}</td>
                            <td>{{$customers->left_eye_without_corr }}</td>
                            <td>{{$customers->right_eye_with_corr }}</td>
                            <td>{{$customers->left_eye_with_corr }}</td>
                            <td>{{$customers->date}}</td>

                        </tr>
                        @endforeach
                    </tbody>
                </table>
Tray2's avatar

@mohammadkhallaf Do a dd on the customer and see what it contains.

You can also change the find to findOrFail

->findOrFail($id);

Then you will get a 404 ModelNotFoundException

mohammadkhallaf's avatar

@Tray2 i have this

App\Models\Customer {#1375 ▼ // app\Http\Controllers\CustomerController.php:80
  #connection: "mysql"
  #table: "customers"
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  +preventsLazyLoading: false
  #perPage: 15
  +exists: true
  +wasRecentlyCreated: false
  #escapeWhenCastingToString: false
  #attributes: array:11 [▼
    "id" => 2
    "personal_id" => 41502333
    "name" => "dsgsdg"
    "clinic" => "asdasd"
    "start_date" => "2023-01-27"
    "phone" => "520365123441"
    "address" => "sdfsd"
    "note" => "sdf"
    "gender" => "انثى"
    "created_at" => "2023-01-02 07:27:47"
    "updated_at" => "2023-01-02 07:27:47"
  ]
  #original: array:11 [▼
    "id" => 2
    "personal_id" => 41502333
    "name" => "dsgsdg"
    "clinic" => "asdasd"
    "start_date" => "2023-01-27"
    "phone" => "520365123441"
    "address" => "sdfsd"
    "note" => "sdf"
    "gender" => "انثى"
    "created_at" => "2023-01-02 07:27:47"
    "updated_at" => "2023-01-02 07:27:47"
  ]
  #changes: []
  #casts: []
  #classCastCache: []
  #attributeCastCache: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: array:4 [▶]
  #touches: []
  +timestamps: true
  #hidden: []
  #visible: []
  #fillable: array:10 [▶]
  #guarded: array:1 [▶]
}
Ben Taylor's avatar

Why are you looping over customers when you are passing through a singular customer to the view?

If you have adopted @tray2 's suggestion, which you should, change the return statement to this:

return view('admin.customer.profile', compact('customer');
mohammadkhallaf's avatar

@Ben Taylor i use this but the table appear empty

<table id="example1" class="table table-bordered table-striped" dir="rtl">
                    <thead>
                        <tr>


                            <th> test id </th>
                            <th>distance</th>
                            <th> right_eye_without_corr </th>
                            <th>left_eye_without_corr</th>
                            <th> right_eye_with_corr </th>
                            <th>left_eye_with_corr</th>
                            <th>date</th>



                        </tr>
                    </thead>
                    <tbody>
                        @foreach ($customers as  $customer)
                        <tr>

                            <td>{{$customers->test_id}}</td>
                            <td>{{$customers->distance }}</td>
                            <td>{{$customers->right_eye_without_corr }}</td>
                            <td>{{$customers->left_eye_without_corr }}</td>
                            <td>{{$customers->right_eye_with_corr }}</td>
                            <td>{{$customers->left_eye_with_corr }}</td>
                            <td>{{$customers->date}}</td>

                        </tr>
                        @endforeach
                    </tbody>
                </table>
Ben Taylor's avatar

So, to modify your blade file

<tbody>
                     
                        <tr>

                            <td>{{$customer->test_id}}</td>
                            <td>{{$customer->distance }}</td>
                            <td>{{$customer->right_eye_without_corr }}</td>
                            <td>{{$customer->left_eye_without_corr }}</td>
                            <td>{{$customer->right_eye_with_corr }}</td>
                            <td>{{$customer->left_eye_with_corr }}</td>
                            <td>{{$customer->date}}</td>

                        </tr>
                        
                    </tbody>
mohammadkhallaf's avatar

@Ben Taylor

<?php

namespace App\Http\Controllers;

use App\Http\Requests\CustomerRequest;
use App\Models\Customer;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Carbon;

class CustomerController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $customers = Customer::latest()->paginate(15);
        return view('admin.customer.index', compact('customers'));
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('admin.customer.create');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(CustomerRequest $request)
    {
        try {
            $request->validate([
                'personal_id'=>'required',
                'name'=>'required',
                'start_date'=>'required|date',
                'gender'=>'required',
                'clinic'=>'required|string'

            ]);
            $customer = Customer::create([
                'personal_id'=>$request->personal_id,
                'name'=>$request->name,
                'start_date'=>$request->start_date,
                'phone'=>$request->phone,
                'address'=>$request->address,
                'note'=>$request->note,
                'clinic'=>$request->clinic,
                'gender'=>$request->gender,
            ]);
            return redirect()->back()->with('success', 'تم اضافة مريض جديد');
        }
        catch (\Throwable $th) {
            return $th;
            return redirect()->back()->with('error', 'حدث خطأ يرجى اعادة المحاول');
        }

    }

    /**
     * Display the specified resource.
     *
     * @param  \App\Models\Customer  $customer
     * @return \Illuminate\Http\Response
     */
    public function show(Customer $customer,$id)
    {
        $customers = Customer::with('appointments', 'finance', 'personaltests', 'test')->findOrFail($id);
        //dd($customers);
        return view('admin.customer.profile', compact('customers'));
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  \App\Models\Customer  $customer
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {

            $customer = Customer::find($id);
            return view('admin.customer.edit', compact('customer'));


    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Customer  $customer
     * @return \Illuminate\Http\Response
     */
    public function update(CustomerRequest $request, Customer $customer,$id)
    {
        Customer::find($id)->update($request->except('_token','_method'));
        return redirect()->route('admin.customer')->with(['success' => 'تم ألتحديث بنجاح']);
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  \App\Models\Customer  $customer
     * @return \Illuminate\Http\Response
     */
    public function destroy($id,customer $customer)
    {try{
         $customer=Customer::findOrFail($id);
        $customer  ->delete();
        return redirect()->route('admin.customer')->with('message','تم الحذف بنجاح');
    }
    catch(Exception $ex){
        return redirect()->route('admin.customer')->with('error','يحب حذف باقي المعلومات اولا');
    }
    }

}

Route::get('/customer', [CustomerController::class, 'index'])->name('admin.customer');
Route::get('/customer/create', [CustomerController::class, 'create'])->name('admin.customer.create');
Route::post('/customer/store', [CustomerController::class, 'store'])->name('admin.customer.store');
Route::get('/customer/edit/{id}', [CustomerController::class, 'edit'])->name('admin.customer.edit');
Route::get('/customer/show/{id}', [CustomerController::class, 'show'])->name('admin.customer.profile');
Route::put('/customer/update/{id}', [CustomerController::class, 'update'])->name('admin.customer.update');
Route::get('/customer/delete/{id}', [CustomerController::class, 'destroy'])->name('admin.customer.delete');
Ben Taylor's avatar

Ok, try this.

Change your route to this


Route::get('/customer/show/{customer}', [CustomerController::class, 'show'])->name('admin.customer.profile');
public function show(Customer $customer)
    {
        $customer->load('appointments', 'finance', 'personaltests', 'test');
        
        return view('admin.customer.profile', compact('customer'));
    }
mohammadkhallaf's avatar

@Ben Taylor


@extends('layouts.master')
@section('title')
patient profile
@endsection
@section('css')

@endsection
@section('title_page1')

@endsection
@section('title_page2')

@endsection
@section('content')
<section class="content">
    <div class="container-fluid">
      <div class="row">
        <div class="col-md-3">

          <!-- Profile Image -->

          <!-- /.card -->

          <!-- About Me Box -->
          <div class="card card-primary">
            <div class="card-header" dir="ltr">
              <h3 class="card-title">About patient </h3>
            </div>
            <!-- /.card-header -->
            <div class="card-body">
              <strong><i class="fas fa-book mr-1"></i> name</strong>

              <p class="text-muted">
               {{$customers->name}}
              </p>

              <hr>

              <strong><i class="fas fa-map-marker-alt mr-1"></i> address</strong>

              <p class="text-muted"> {{$customers->address}}</p>

              <hr>

              <strong><i class="fas fa-pencil-alt mr-1"></i> national id</strong>

              <p class="text-muted">
                <span class="tag tag-danger">{{$customers->personal_id}}</span>

              </p>

              <hr>

              <strong><i class="far fa-file-alt mr-1"></i> mobile</strong>

              <p class="text-muted">{{$customers->phone}}</p>
              <hr>

              <strong><i class="far fa-file-alt mr-1"></i> gender</strong>

              <p class="text-muted">{{$customers->gender}}</p>
            </div>
            <!-- /.card-body -->
          </div>
          <!-- /.card -->
        </div>
        <!-- /.col -->
        <div class="col-md-9">
          <div class="card">
            <div class="card-header p-2">
              <ul class="nav nav-pills">
                <li class="nav-item"><a class="nav-link active" href="#activity" data-toggle="tab">tests</a></li>
                <li class="nav-item"><a class="nav-link" href="#timeline" data-toggle="tab">Timeline</a></li>
                <li class="nav-item"><a class="nav-link" href="#settings" data-toggle="tab">Settings</a></li>
              </ul>
            </div><!-- /.card-header -->
            <div class="card-body">
              <div class="tab-content">
                <div class="tab-pane active" id="activity">
                  <!-- Post -->

                  <!-- /.post -->

                  <!-- Post -->
                  <table id="example1" class="table table-bordered table-striped" dir="rtl">
                    <thead>
                        <tr>


                            <th> test id </th>
                            <th>distance</th>
                            <th> right_eye_without_corr </th>
                            <th>left_eye_without_corr</th>
                            <th> right_eye_with_corr </th>
                            <th>left_eye_with_corr</th>
                            <th>date</th>



                        </tr>
                    </thead>
                    <tbody>
                        @foreach ($customers as  $customer)
                        <tr>
                            <td>{{$customers->test_id}}</td>
                            <td>{{$customers->distance }}</td>
                            <td>{{$customers->right_eye_without_corr }}</td>
                            <td>{{$customers->left_eye_without_corr }}</td>
                            <td>{{$customers->right_eye_with_corr }}</td>
                            <td>{{$customers->left_eye_with_corr }}</td>
                            <td>{{$customers->date}}</td>

                        </tr>
                        @endforeach
                    </tbody>
                </table>
                  <!-- /.post -->
                </div>
                <!-- /.tab-pane -->
                <div class="tab-pane" id="timeline">
                  <!-- The timeline -->
                  <div class="timeline timeline-inverse">
                    <!-- timeline time label -->
                    <div class="time-label">
                      <span class="bg-danger">
                        10 Feb. 2014
                      </span>
                    </div>
                    <!-- /.timeline-label -->
                    <!-- timeline item -->
                    <div>
                      <i class="fas fa-envelope bg-primary"></i>

                      <div class="timeline-item">
                        <span class="time"><i class="far fa-clock"></i> 12:05</span>

                        <h3 class="timeline-header"><a href="#">Support Team</a> sent you an email</h3>

                        <div class="timeline-body">
                          Etsy doostang zoodles disqus groupon greplin oooj voxy zoodles,
                          weebly ning heekya handango imeem plugg dopplr jibjab, movity
                          jajah plickers sifteo edmodo ifttt zimbra. Babblely odeo kaboodle
                          quora plaxo ideeli hulu weebly balihoo...
                        </div>
                        <div class="timeline-footer">
                          <a href="#" class="btn btn-primary btn-sm">Read more</a>
                          <a href="#" class="btn btn-danger btn-sm">Delete</a>
                        </div>
                      </div>
                    </div>
                    <!-- END timeline item -->
                    <!-- timeline item -->
                    <div>
                      <i class="fas fa-user bg-info"></i>

                      <div class="timeline-item">
                        <span class="time"><i class="far fa-clock"></i> 5 mins ago</span>

                        <h3 class="timeline-header border-0"><a href="#">Sarah Young</a> accepted your friend request
                        </h3>
                      </div>
                    </div>
                    <!-- END timeline item -->
                    <!-- timeline item -->
                    <div>
                      <i class="fas fa-comments bg-warning"></i>

                      <div class="timeline-item">
                        <span class="time"><i class="far fa-clock"></i> 27 mins ago</span>

                        <h3 class="timeline-header"><a href="#">Jay White</a> commented on your post</h3>

                        <div class="timeline-body">
                          Take me to your leader!
                          Switzerland is small and neutral!
                          We are more like Germany, ambitious and misunderstood!
                        </div>
                        <div class="timeline-footer">
                          <a href="#" class="btn btn-warning btn-flat btn-sm">View comment</a>
                        </div>
                      </div>
                    </div>
                    <!-- END timeline item -->
                    <!-- timeline time label -->
                    <div class="time-label">
                      <span class="bg-success">
                        3 Jan. 2014
                      </span>
                    </div>
                    <!-- /.timeline-label -->
                    <!-- timeline item -->
                    <div>
                      <i class="fas fa-camera bg-purple"></i>

                      <div class="timeline-item">
                        <span class="time"><i class="far fa-clock"></i> 2 days ago</span>

                        <h3 class="timeline-header"><a href="#">Mina Lee</a> uploaded new photos</h3>

                        <div class="timeline-body">
                          <img src="https://placehold.it/150x100" alt="...">
                          <img src="https://placehold.it/150x100" alt="...">
                          <img src="https://placehold.it/150x100" alt="...">
                          <img src="https://placehold.it/150x100" alt="...">
                        </div>
                      </div>
                    </div>
                    <!-- END timeline item -->
                    <div>
                      <i class="far fa-clock bg-gray"></i>
                    </div>
                  </div>
                </div>
                <!-- /.tab-pane -->

                <div class="tab-pane" id="settings">
                  <form class="form-horizontal">
                    <div class="form-group row">
                      <label for="inputName" class="col-sm-2 col-form-label">Name</label>
                      <div class="col-sm-10">
                        <input type="email" class="form-control" id="inputName" placeholder="Name">
                      </div>
                    </div>
                    <div class="form-group row">
                      <label for="inputEmail" class="col-sm-2 col-form-label">Email</label>
                      <div class="col-sm-10">
                        <input type="email" class="form-control" id="inputEmail" placeholder="Email">
                      </div>
                    </div>
                    <div class="form-group row">
                      <label for="inputName2" class="col-sm-2 col-form-label">Name</label>
                      <div class="col-sm-10">
                        <input type="text" class="form-control" id="inputName2" placeholder="Name">
                      </div>
                    </div>
                    <div class="form-group row">
                      <label for="inputExperience" class="col-sm-2 col-form-label">Experience</label>
                      <div class="col-sm-10">
                        <textarea class="form-control" id="inputExperience" placeholder="Experience"></textarea>
                      </div>
                    </div>
                    <div class="form-group row">
                      <label for="inputSkills" class="col-sm-2 col-form-label">Skills</label>
                      <div class="col-sm-10">
                        <input type="text" class="form-control" id="inputSkills" placeholder="Skills">
                      </div>
                    </div>
                    <div class="form-group row">
                      <div class="offset-sm-2 col-sm-10">
                        <div class="checkbox">
                          <label>
                            <input type="checkbox"> I agree to the <a href="#">terms and conditions</a>
                          </label>
                        </div>
                      </div>
                    </div>
                    <div class="form-group row">
                      <div class="offset-sm-2 col-sm-10">
                        <button type="submit" class="btn btn-danger">Submit</button>
                      </div>
                    </div>
                  </form>
                </div>
                <!-- /.tab-pane -->
              </div>
              <!-- /.tab-content -->
            </div><!-- /.card-body -->
          </div>
          <!-- /.card -->
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
    </div><!-- /.container-fluid -->
  </section>
@endsection






@section('scripts')

@endsection

Tray2's avatar

@mohammadkhallaf

Many customers => $customers One customer => $customer

You need to make sure that it you pass customer to your view, that you use customer and not customers.

1 like
mohammadkhallaf's avatar

@Ben Taylor the table still empty

@extends('layouts.master')
@section('title')
patient profile
@endsection
@section('css')

@endsection
@section('title_page1')

@endsection
@section('title_page2')

@endsection
@section('content')
<section class="content">
    <div class="container-fluid">
      <div class="row">
        <div class="col-md-3">

          <!-- Profile Image -->

          <!-- /.card -->

          <!-- About Me Box -->
          <div class="card card-primary">
            <div class="card-header" dir="ltr">
              <h3 class="card-title">About patient </h3>
            </div>
            <!-- /.card-header -->
            <div class="card-body">
              <strong><i class="fas fa-book mr-1"></i> name</strong>

              <p class="text-muted">
               {{$customer->name}}
              </p>

              <hr>

              <strong><i class="fas fa-map-marker-alt mr-1"></i> address</strong>

              <p class="text-muted"> {{$customer->address}}</p>

              <hr>

              <strong><i class="fas fa-pencil-alt mr-1"></i> national id</strong>

              <p class="text-muted">
                <span class="tag tag-danger">{{$customer->personal_id}}</span>

              </p>

              <hr>

              <strong><i class="far fa-file-alt mr-1"></i> mobile</strong>

              <p class="text-muted">{{$customer->phone}}</p>
              <hr>

              <strong><i class="far fa-file-alt mr-1"></i> gender</strong>

              <p class="text-muted">{{$customer->gender}}</p>
            </div>
            <!-- /.card-body -->
          </div>
          <!-- /.card -->
        </div>
        <!-- /.col -->
        <div class="col-md-9">
          <div class="card">
            <div class="card-header p-2">
              <ul class="nav nav-pills">
                <li class="nav-item"><a class="nav-link active" href="#activity" data-toggle="tab">tests</a></li>
                <li class="nav-item"><a class="nav-link" href="#timeline" data-toggle="tab">Timeline</a></li>
                <li class="nav-item"><a class="nav-link" href="#settings" data-toggle="tab">Settings</a></li>
              </ul>
            </div><!-- /.card-header -->
            <div class="card-body">
              <div class="tab-content">
                <div class="tab-pane active" id="activity">
                  <!-- Post -->

                  <!-- /.post -->

                  <!-- Post -->
                  <table id="example1" class="table table-bordered table-striped" dir="rtl">
                    <thead>
                        <tr>


                            <th> test id </th>
                            <th>distance</th>
                            <th> right_eye_without_corr </th>
                            <th>left_eye_without_corr</th>
                            <th> right_eye_with_corr </th>
                            <th>left_eye_with_corr</th>
                            <th>date</th>



                        </tr>
                    </thead>
                    <tbody>

                        <tr>
                            <td>{{$customer->test_id}}</td>
                            <td>{{$customer->distance }}</td>
                            <td>{{$customer->right_eye_without_corr }}</td>
                            <td>{{$customer->left_eye_without_corr }}</td>
                            <td>{{$customer->right_eye_with_corr }}</td>
                            <td>{{$customer->left_eye_with_corr }}</td>
                            <td>{{$customer->date}}</td>

                        </tr>

                    </tbody>
                </table>
                  <!-- /.post -->
                </div>
                <!-- /.tab-pane -->
                <div class="tab-pane" id="timeline">
                  <!-- The timeline -->
                  <div class="timeline timeline-inverse">
                    <!-- timeline time label -->
                    <div class="time-label">
                      <span class="bg-danger">
                        10 Feb. 2014
                      </span>
                    </div>
                    <!-- /.timeline-label -->
                    <!-- timeline item -->
                    <div>
                      <i class="fas fa-envelope bg-primary"></i>

                      <div class="timeline-item">
                        <span class="time"><i class="far fa-clock"></i> 12:05</span>

                        <h3 class="timeline-header"><a href="#">Support Team</a> sent you an email</h3>

                        <div class="timeline-body">
                          Etsy doostang zoodles disqus groupon greplin oooj voxy zoodles,
                          weebly ning heekya handango imeem plugg dopplr jibjab, movity
                          jajah plickers sifteo edmodo ifttt zimbra. Babblely odeo kaboodle
                          quora plaxo ideeli hulu weebly balihoo...
                        </div>
                        <div class="timeline-footer">
                          <a href="#" class="btn btn-primary btn-sm">Read more</a>
                          <a href="#" class="btn btn-danger btn-sm">Delete</a>
                        </div>
                      </div>
                    </div>
                    <!-- END timeline item -->
                    <!-- timeline item -->
                    <div>
                      <i class="fas fa-user bg-info"></i>

                      <div class="timeline-item">
                        <span class="time"><i class="far fa-clock"></i> 5 mins ago</span>

                        <h3 class="timeline-header border-0"><a href="#">Sarah Young</a> accepted your friend request
                        </h3>
                      </div>
                    </div>
                    <!-- END timeline item -->
                    <!-- timeline item -->
                    <div>
                      <i class="fas fa-comments bg-warning"></i>

                      <div class="timeline-item">
                        <span class="time"><i class="far fa-clock"></i> 27 mins ago</span>

                        <h3 class="timeline-header"><a href="#">Jay White</a> commented on your post</h3>

                        <div class="timeline-body">
                          Take me to your leader!
                          Switzerland is small and neutral!
                          We are more like Germany, ambitious and misunderstood!
                        </div>
                        <div class="timeline-footer">
                          <a href="#" class="btn btn-warning btn-flat btn-sm">View comment</a>
                        </div>
                      </div>
                    </div>
                    <!-- END timeline item -->
                    <!-- timeline time label -->
                    <div class="time-label">
                      <span class="bg-success">
                        3 Jan. 2014
                      </span>
                    </div>
                    <!-- /.timeline-label -->
                    <!-- timeline item -->
                    <div>
                      <i class="fas fa-camera bg-purple"></i>

                      <div class="timeline-item">
                        <span class="time"><i class="far fa-clock"></i> 2 days ago</span>

                        <h3 class="timeline-header"><a href="#">Mina Lee</a> uploaded new photos</h3>

                        <div class="timeline-body">
                          <img src="https://placehold.it/150x100" alt="...">
                          <img src="https://placehold.it/150x100" alt="...">
                          <img src="https://placehold.it/150x100" alt="...">
                          <img src="https://placehold.it/150x100" alt="...">
                        </div>
                      </div>
                    </div>
                    <!-- END timeline item -->
                    <div>
                      <i class="far fa-clock bg-gray"></i>
                    </div>
                  </div>
                </div>
                <!-- /.tab-pane -->

                <div class="tab-pane" id="settings">
                  <form class="form-horizontal">
                    <div class="form-group row">
                      <label for="inputName" class="col-sm-2 col-form-label">Name</label>
                      <div class="col-sm-10">
                        <input type="email" class="form-control" id="inputName" placeholder="Name">
                      </div>
                    </div>
                    <div class="form-group row">
                      <label for="inputEmail" class="col-sm-2 col-form-label">Email</label>
                      <div class="col-sm-10">
                        <input type="email" class="form-control" id="inputEmail" placeholder="Email">
                      </div>
                    </div>
                    <div class="form-group row">
                      <label for="inputName2" class="col-sm-2 col-form-label">Name</label>
                      <div class="col-sm-10">
                        <input type="text" class="form-control" id="inputName2" placeholder="Name">
                      </div>
                    </div>
                    <div class="form-group row">
                      <label for="inputExperience" class="col-sm-2 col-form-label">Experience</label>
                      <div class="col-sm-10">
                        <textarea class="form-control" id="inputExperience" placeholder="Experience"></textarea>
                      </div>
                    </div>
                    <div class="form-group row">
                      <label for="inputSkills" class="col-sm-2 col-form-label">Skills</label>
                      <div class="col-sm-10">
                        <input type="text" class="form-control" id="inputSkills" placeholder="Skills">
                      </div>
                    </div>
                    <div class="form-group row">
                      <div class="offset-sm-2 col-sm-10">
                        <div class="checkbox">
                          <label>
                            <input type="checkbox"> I agree to the <a href="#">terms and conditions</a>
                          </label>
                        </div>
                      </div>
                    </div>
                    <div class="form-group row">
                      <div class="offset-sm-2 col-sm-10">
                        <button type="submit" class="btn btn-danger">Submit</button>
                      </div>
                    </div>
                  </form>
                </div>
                <!-- /.tab-pane -->
              </div>
              <!-- /.tab-content -->
            </div><!-- /.card-body -->
          </div>
          <!-- /.card -->
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
    </div><!-- /.container-fluid -->
  </section>
@endsection






@section('scripts')

@endsection

mohammadkhallaf's avatar

@Ben Taylor

pp\Models\Customer {#416 ▼ // app\Http\Controllers\CustomerController.php:78
  #connection: null
  #table: null
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  +preventsLazyLoading: false
  #perPage: 15
  +exists: false
  +wasRecentlyCreated: false
  #escapeWhenCastingToString: false
  #attributes: []
  #original: []
  #changes: []
  #casts: []
  #classCastCache: []
  #attributeCastCache: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: array:4 [▼
    "appointments" => Illuminate\Database\Eloquent\Collection {#1369 ▼
      #items: []
      #escapeWhenCastingToString: false
    }
    "finance" => Illuminate\Database\Eloquent\Collection {#1374 ▼
      #items: []
      #escapeWhenCastingToString: false
    }
    "personaltests" => Illuminate\Database\Eloquent\Collection {#1375 ▼
      #items: []
      #escapeWhenCastingToString: false
    }
    "test" => Illuminate\Database\Eloquent\Collection {#411 ▼
      #items: []
      #escapeWhenCastingToString: false
    }
  ]
  #touches: []
  +timestamps: true
  #hidden: []
  #visible: []
  #fillable: array:10 [▼
    0 => "personal_id"
    1 => "name"
    2 => "clinic"
    3 => "start_date"
    4 => "phone"
    5 => "address"
    6 => "note"
    7 => "gender"
    8 => "created_at"
    9 => "updated_at"
  ]
  #guarded: array:1 [▼
    0 => "*"
  ]
}

Ben Taylor's avatar
Level 35

@mohammadkhallaf of course the table is empty. Your customer model doesn't have test_id, distance etc on it. Where are you expecting to get these from?

Snapey's avatar

your initial question shows some serious issues with the design of your data

why do all your models share the same primary key value?

Tray2's avatar

@mohammadkhallaf You should never tell the database which id it should store, they are usually incremented automatically. The only time that you set an id is when it's a foreign key id like user_id, patient_id and so on.

1 like

Please or to participate in this conversation.