1<?php
2
3namespace App\Http\Controllers;
4
5use Illuminate\Http\Request;
6use App\Ticket;
7
8class TicketController extends Controller
9{
10 /**
11 * Display a listing of the resource.
12 *
13 * @return \Illuminate\Http\Response
14 */
15 public function index()
16 {
17 $patients = Patient::where('user_id', auth()->user()->id)->get();
18
19 return view('patients.index',compact('patients'));
20 }
21
22 /**
23 * Show the form for creating a new resource.
24 *
25 * @return \Illuminate\Http\Response
26 */
27 public function create()
28 {
29 return view('patients.create');
30 }
31
32 /**
33 * Store a newly created resource in storage.
34 *
35 * @param \Illuminate\Http\Request $request
36 * @return \Illuminate\Http\Response
37 */
38 public function store(Request $request)
39 {
40 $ticket = new Patient();
41 $data = $this->validate($request, [
42 'name'=>'required',
43 'surname'=> 'required'
44 'id_number'=> 'required'
45 ]);
46
47 $patient->savePatient($data);
48 return redirect('/home')->with('success', 'New patient has been succesfully created');
49 }
50
51 /**
52 * Display the specified resource.
53 *
54 * @param int $id
55 * @return \Illuminate\Http\Response
56 */
57 public function show($id)
58 {
59 //
60 }
61
62 /**
63 * Show the form for editing the specified resource.
64 *
65 * @param int $id
66 * @return \Illuminate\Http\Response
67 */
68 public function edit($id)
69 {
70 $patient = Patient::where('user_id', auth()->user()->id)
71 ->where('id', $id)
72 ->first();
73
74 return view('patients.edit', compact('patient', 'id'));
75 }
76
77 /**
78 * Update the specified resource in storage.
79 *
80 * @param \Illuminate\Http\Request $request
81 * @param int $id
82 * @return \Illuminate\Http\Response
83 */
84 public function update(Request $request, $id)
85 {
86 $patient = new Patient();
87 $data = $this->validate($request, [
88 'name'=>'required',
89 'surname'=> 'required'
90 'id_number'=> 'required'
91 ]);
92 $data['id'] = $id;
93 $patient->updatePatient($data);
94
95 return redirect('/home')->with('success', 'Patient Information was updated succesfully');
96 }
97
98 /**
99 * Remove the specified resource from storage.
100 *
101 * @param int $id
102 * @return \Illuminate\Http\Response
103 */
104 public function destroy($id)
105 {
106 $patient = Patient::find($id);
107 $patient->delete();
108
109 return redirect('/home')->with('success', 'The patient has been deleted!!');
110 }
111}
1@extends('layouts.app')
2
3@section('content')
4<div class="container">
5 <table class="table table-striped">
6 <thead>
7 <tr>
8 <td>ID</td>
9 <td>Title</td>
10 <td>Description</td>
11 <td colspan="2">Action</td>
12 </tr>
13 </thead>
14 <tbody>
15 @foreach($patients as $patient)
16 <tr>
17 <td>{{$ticket->id}}</td>
18 <td>{{$ticket->name}}</td>
19 <td>{{$ticket->surname}}</td>
20 <td><a href="{{action(PatientController@edit',$patient->id)}}" class="btn btn-primary">Edit</a></td>
21 <td>
22 <form action="{{action('PatientController@destroy', $patient->id)}}" method="post">
23 {{csrf_field()}}
24 <input name="_method" type="hidden" value="DELETE">
25 <button class="btn btn-danger" type="submit">Delete</button>
26 </form>
27 </td>
28 </tr>
29 @endforeach
30 </tbody>
31 </table>
32<div>
33@endsection
1<!-- create.blade.php -->
2
3@extends('layout')
4
5@section('content')
6<style>
7 .uper {
8 margin-top: 40px;
9 }
10</style>
11<div class="card uper">
12 <div class="card-header">
13 Add Games Data
14 </div>
15 <div class="card-body">
16 @if ($errors->any())
17 <div class="alert alert-danger">
18 <ul>
19 @foreach ($errors->all() as $error)
20 <li>{{ $error }}</li>
21 @endforeach
22 </ul>
23 </div><br />
24 @endif
25 <form method="post" action="{{ route('games.store') }}">
26 <div class="form-group">
27 @csrf
28 <label for="country_name">Game Name:</label>
29 <input type="text" class="form-control" name="name"/>
30 </div>
31 <div class="form-group">
32 <label for="cases">Price :</label>
33 <input type="text" class="form-control" name="price"/>
34 </div>
35 <button type="submit" class="btn btn-primary">Add Game</button>
36 </form>
37 </div>
38</div>
39@endsection