I am working on a job search project online with Laravel5. My problem is this: I want to tweak the jobber list by clicking on a category checkbox. But my jobber table is not directly related to the category table. Here is the structure jobberTable-> serviceCatTable-> CategoryTable. Please, I need your help. Here is a picture for illustrious
Here is the jobber model
class User extends Authenticatable
{ use Notifiable, EntrustUserTrait;
protected $fillable = [ 'name', 'surname', 'email', 'phone',
'password','type', ];
protected $hidden = [ 'password', 'remember_token', ];
public function service(): BelongsTo
{
return $this->belongsTo(Service::class);
}
}
Here is the service model
class Service extends Model
{ protected $fillable = ['category_id','name','description'];
public function category(): BelongsTo
{
return $this->belongsTo(Category::class);
}
public function users(): BelongsTo
{
return $this->belongsToMany(User::class, 'service_id');
}
}
Here is the category model
class Category extends Model
{
protected $fillable = ['name','description','confirmed'];
public function service(): BelongsTo
{
return $this->belongsTo(Service::class, 'category_id');
}
}
Please, I need your help. Thanks
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2HpZ9Y5
via IFTTT
Aucun commentaire:
Enregistrer un commentaire