<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany; // Add this

class Shop extends Model
{
    use HasFactory;

    protected $fillable = [
        'user_id',
        'name',
        'slug',
        'tagline',
        'contact_phone',
        'contact_email',
        'address_line_1',
        'address_line_2',
        'city',
        'state',
        'zip_code',
        'latitude',
        'longitude',
        'opening_time',
        'closing_time',
        'logo_path',
        'cover_image_path',
        'status',
        'is_open',
    ];

    /**
     * Get the user (seller) that owns the shop.
     */
    public function owner()
    {
        return $this->belongsTo(User::class, 'user_id');
    }

    // ------------------------------------
    // ADDED RELATIONSHIPS FOR CATEGORIES AND ITEMS
    // ------------------------------------

    /**
     * Get the categories for the shop.
     */
    public function categories(): HasMany
    {
        return $this->hasMany(Category::class);
    }

    /**
     * Get the items (products) for the shop.
     */
    public function items(): HasMany
    {
        return $this->hasMany(Item::class);
    }
}