vendredi 7 mai 2021

table data relation is not entered, encountered an error Method Illuminate \ Database \ Eloquent \ Collection :: links does not exist

Ticket.php

Protected $table = 'tickets';

Protected $fillable = ['user_id','kategori_id','judul','prioritas_id','status_id','message','file_tambahan'];

public function user()
{
    return $this->belongsTo(User::class);
}

User.php

protected $table = 'users';

protected $fillable = [
    'avatar','nama_lengkap', 'email', 'password',
];

public function getAvatar()
{
    if(!$this->avatar)
    {
        return asset('images/default.png');
    }

    return asset('images/'.$this->avatar);
}


public function ticket()
{
    return $this->hasMany(Ticket::class);
}

TicketController.php


use App\Model\Ticket;
use App\Model\User;
use App\Model\Kategori;
use App\Model\Prioritas;
use App\Model\Status;

class TicketController extends Controller
{
  
    public function index()
    {
        $data = Ticket::with('User','Kategori','Prioritas','Status')->get();
        return view('admin.crud_ticket.index', compact('data'));
    }

index.blade.php

@foreach($data as $d)
<tr role="row" class="odd">
    <td></td>
</tr>
@endforeach
    

I keep getting the same error over and over again, I do relationships between tables

namely in the user table, category, priority, status. and cause an error like this, if you have a solution please help me

Method Illuminate\Database\Eloquent\Collection::links does not exist. (View: C:\xampp\htdocs\Helpdesk\resources\views\admin\crud_ticket\index.blade.php)



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3haRZY8
via IFTTT

Aucun commentaire:

Enregistrer un commentaire