Advertisement
rzaglinskiy

Untitled

Jul 28th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.35 KB | None | 0 0
  1. MODEL
  2. class Complaint extends Model
  3. {
  4.     use CrudTrait;
  5.  
  6.     protected $table = 'complaint';
  7.  
  8.     protected $primaryKey = 'id';
  9.  
  10.     public $timestamps = false;
  11.     protected $fillable = ['title', 'body', 'visibility', 'created_date', 'updated_date', 'valid', 'User_id', 'Diagnosis_id', 'insurance', 'Geo_id'];
  12.  
  13.     public function user()
  14.     {
  15.         return $this->belongsTo('App\Models\User', 'id');
  16.     }
  17.  
  18. //    public function symptoms(){
  19. //        return $this->belongsToMany('App\Models\Symptom', 'complaint_symptom', 'Complaint_id', 'Symptom_id');
  20. //    }
  21.  
  22. }
  23.  
  24. CONTROLLER
  25.  public function index()
  26.     {
  27.         return view('admin.complaint.index', ['complaints' => Complaint::paginate(10), 'count' => Complaint::count()]);
  28.     }
  29.  
  30. VIEW
  31.  @foreach ($complaints as $complaint)
  32.                     <tr>
  33.                         <td>{{ $complaint->id }}</td>
  34.                         <td>{{ $complaint->title }}</td>
  35.                         <td>{{ $complaint->user->email }}</td>
  36.                         <td>{{ $complaint->created }}</td>
  37.                         <td>{{ $complaint->visibility }}</td>
  38.                         <td>{{ $complaint->valid }}</td>
  39.                         <td>1</td>
  40.                         <td><a href="{{ route('complaint.edit', $complaint->id) }}">Edit</a></td>
  41.                     </tr>
  42.                 @endforeach
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement