You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<?php
/**
* Created by Reliese Model.
*/
namespace App\Base;
use App\Category;
use App\Event;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class Category
*
* @property int $id
* @property string $title
* @property int $parent_id
* @property Carbon $created_at
* @property Carbon $updated_at
* @property string $deleted_at
*
* @property Category $category
* @property Collection|Category[] $categories
* @property Collection|Event[] $events
*
* @package App\Base
*/
class Category extends Model
{
use SoftDeletes;
protected $table = 'bszcategories';
public static $snakeAttributes = false;
protected $casts = [
'parent_id' => 'int'
];
public function category()
{
return $this->belongsTo(Category::class, 'parent_id');
}
public function categories()
{
return $this->hasMany(Category::class, 'parent_id');
}
public function events()
{
return $this->hasMany(Event::class);
}
}
and
<?php
namespace App;
use App\Base\Category as BaseCategory;
class Category extends BaseCategory
{
protected $fillable = [
'title',
'parent_id'
];
}
Gives error on use App\Category; line, because it creates a circular reference, which is not needed and wrong. When you remove use App\Category; in the base class, everything works fine. Just a heads up.
The text was updated successfully, but these errors were encountered:
Hello,
Suppose you have a migration like this, and you are using base classes:
Which produces:
and
Gives error on
use App\Category;
line, because it creates a circular reference, which is not needed and wrong. When you removeuse App\Category;
in the base class, everything works fine. Just a heads up.The text was updated successfully, but these errors were encountered: