Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MODEL
- class Complaint extends Model
- {
- use CrudTrait;
- protected $table = 'complaint';
- protected $primaryKey = 'id';
- public $timestamps = false;
- protected $fillable = ['title', 'body', 'visibility', 'created_date', 'updated_date', 'valid', 'User_id', 'Diagnosis_id', 'insurance', 'Geo_id'];
- public function user()
- {
- return $this->belongsTo('App\Models\User', 'id');
- }
- // public function symptoms(){
- // return $this->belongsToMany('App\Models\Symptom', 'complaint_symptom', 'Complaint_id', 'Symptom_id');
- // }
- }
- CONTROLLER
- public function index()
- {
- return view('admin.complaint.index', ['complaints' => Complaint::paginate(10), 'count' => Complaint::count()]);
- }
- VIEW
- @foreach ($complaints as $complaint)
- <tr>
- <td>{{ $complaint->id }}</td>
- <td>{{ $complaint->title }}</td>
- <td>{{ $complaint->user->email }}</td>
- <td>{{ $complaint->created }}</td>
- <td>{{ $complaint->visibility }}</td>
- <td>{{ $complaint->valid }}</td>
- <td>1</td>
- <td><a href="{{ route('complaint.edit', $complaint->id) }}">Edit</a></td>
- </tr>
- @endforeach
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement