ryangjchandler / orbit

A flat-file database driver for Eloquent. 🗄
MIT License
867 stars 39 forks source link

bug #165

Closed bahramzade closed 7 months ago

bahramzade commented 7 months ago

Orbit\Actions\MaybeCreateOrbitDirectories::execute(): Argument #1 ($model) must be of type (Orbit\Contracts\Orbit&Illuminate\Database\Eloquent\Model)|null, App\Models\ChildCategory given, called in /Users/rasulchopurov/Herd/laravel-package-ocean/vendor/ryangjchandler/orbit/src/Concerns/Orbital.php on line 29

ryangjchandler commented 7 months ago

@bahramzade Can you share the code for the model?

bahramzade commented 7 months ago

error in this model

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Schema\Blueprint;
use Orbit\Concerns\Orbital;

class ChildCategory extends Model
{
    use Orbital;

    public function schema(Blueprint $table): void
    {
        $table->id();
        $table->string('name')->unique();
        $table->string('activeClass')->nullable();
        $table->text('content')->nullable();
    }
}
bahramzade commented 7 months ago

another model Category is worked not problem


<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Schema\Blueprint;
use Orbit\Concerns\Orbital;
use Orbit\Contracts\Orbit;
use Rennokki\QueryCache\Traits\QueryCacheable;

class Category extends Model implements Orbit
{
    use HasFactory;
    use Orbital;
    use QueryCacheable;

    public $timestamps = false;

    public $cacheFor = 3600 * 24; // In seconds

    protected static $flushCacheOnUpdate = true;

    public function schema(Blueprint $table): void
    {
        $table->id();
        $table->string('name')->unique();
        $table->string('activeClass')->unique();
        $table->text('content')->nullable();
    }

    public function packages()
    {
        return $this->hasMany(Package::class);
    }

    public function childCategories()
    {
        return $this->belongsTo(ChildCategories::class);
    }
}
ryangjchandler commented 7 months ago

Yep, you need to implement the Orbit interface. That's the problem.

bahramzade commented 6 months ago

Yep, you need to implement the Orbit interface. That's the problem.

use Orbit\Contracts\Orbit;

not found why?