Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Creating non-"root" Models creates duplicates #61

Open
hhhc opened this issue Feb 6, 2023 · 2 comments
Open

[Bug] Creating non-"root" Models creates duplicates #61

hhhc opened this issue Feb 6, 2023 · 2 comments
Assignees
Labels
bug Something isn't working Priority: MUST

Comments

@hhhc
Copy link

hhhc commented Feb 6, 2023

Bug report

What I did

Tried to create a new model with App\Models\Tennis\Court

What I expected to happen

I expected 1 model Court.php to be created in the directory app/models/tennis.

What happened

It created 2 models:

app/models/Court.php:

<?php

namespace App\Models;

use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Court extends Model
{
    use CrudTrait;
    use HasFactory;

    /*
    |--------------------------------------------------------------------------
    | GLOBAL VARIABLES
    |--------------------------------------------------------------------------
    */

    protected $table = 'courts';
    // protected $primaryKey = 'id';
    // public $timestamps = false;
    protected $guarded = ['id'];
    // protected $fillable = [];
    // protected $hidden = [];
    // protected $dates = [];

}

and

app/models/tennis/Court.php:

<?php

namespace App\Models\Tennis;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Court extends Model
{
    use HasFactory;

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'CourtId',
        'CourtName',
        'CityName',
        'place_id',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'id' => 'integer',
    ];

    public function place()
    {
        return $this->belongsTo(\App\Models\Place::class, 'place_id');
    }
}

Also, the CourtCrudController.php did not use the subdirectory structure which I would assume would make a lot of sense. Same for Requests.

I

@hhhc
Copy link
Author

hhhc commented Feb 6, 2023

Just recognized that the generated CRUD Controller does not contain any fields from the model inside
setupCreateOperation() and setupListOperation() functions.

@tabacitu
Copy link
Member

tabacitu commented Feb 14, 2023

Ouch - sounds like a bug there... it definitely shouldn't have created 2 models. Thanks for letting us know 🙏

@pxpm could you please investigate?

@tabacitu tabacitu added the bug Something isn't working label Feb 14, 2023
@tabacitu tabacitu removed this from This week May 22, 2023
@tabacitu tabacitu moved this to Todo in Backpack v5.4+ May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Priority: MUST
Projects
Status: Todo
Development

No branches or pull requests

3 participants