8 months ago

Relationship - ServiceCategory and Service

Posted 8 months ago by siusiak1000

Hello! I have services and a category of services. I can not deal with relationships. How to do it.? Do I have to use a pivot table or can I solve it differently? If so, where can I save the relationship?

ServiceCategory - model

class ServiceCategory extends Model
    public $fillable = ['name', 'order'];


ServiceCategory - migration

        Schema::create('service_categories', function (Blueprint $table) {

Service - Model

class Service extends Model
    protected $fillable = [



        $service = Service::create([
            'name' => $request->name,
            'category' => $request->category,
            'position' => $request->position,
            'duration' => $request->duration,
            'price' => $request->price,
            'old_price' => $request->old_price,
            'vat' => $request->vat,
            'promotion' => $request->promotion,
            'public_desc' => $request->public_desc,
            'private_desc' => $request->private_desc,
            'photo' => $name_photo,

Service - migration

        Schema::create('services', function (Blueprint $table) {

Please sign in or create an account to participate in this conversation.