Closed Davidinho241 closed 4 years ago
Hello there! Thanks for opening your first issue on this repo!
Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.
Backpack communication channels:
backpack-for-laravel
tag;Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.
Thank you!
-- Justin Case The Backpack Robot
My guess is that you have a role
as attribute and a role
as relation.
You could use for attribute getRoleNameAttribute
for example.
I am going to close this as I don't think this is a bug with backpack.
If I am wrong, and sometimes I am, please re-open.
Best, Pedro
My guess is that you have a
role
as attribute and arole
as relation.You could use for attribute
getRoleNameAttribute
for example.I am going to close this as I don't think this is a bug with backpack.
If I am wrong, and sometimes I am, please re-open.
Best, Pedro
I have remove the function getRoleAttribute and getGenderAttribute but the issue remain.
I have also try to use the getRoleNameAttribute but nothing.
I have clear the cache but nothing
I think the issue is because, the store function try to insert the value of the role
$item->{$relationMethod}->update($relationData['values']);
Please help
Oups!
Looks like this is a support request, not a bug/feature. Could you please repost on StackOverflow, using the backpack-for-laravel
tag?
Background: Here at Backpack we use Github Issues only for tracking bugs and features, not individual implementation issues. This helps a lot in keeping our focus on improving Backpack. Thanks a lot for understanding!
Here are all the Backpack communication mediums:
backpack-for-laravel
tag; this is recommended for most questions, since other developers can then find the answer on a simple Google search; also, people get points for answering - and who doesn't like StackOverflow points?!Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or StackOverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.
Thank you!
-- Justin Case The Backpack Robot
PS. In case I mistakenly closed your issue, yell :-) I'm a robot, I make mistakes.
Bug report
What I did
Hi Team, I have use Backpack like this :
The controller
`/**
@property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud */ class UserCrudController extends CrudController { use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation; use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation; use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation; use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation; use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation { show as traitShow; }
public function setup() { $this->crud->setModel('App\Models\User'); $this->crud->setRoute(config('backpack.base.route_prefix') . '/user'); $this->crud->setEntityNameStrings('user', 'users'); $this->crud->addField([ 'label' => "Photo de profile", 'name' => "image", 'type' => 'image', 'crop' => true, // set to true to allow cropping, false to disable 'upload' => true, 'aspect_ratio' => 1, // ommit or set to 0 to allow any aspect ratio // 'disk' => 's3_bucket', // in case you need to show images from a different disk // 'prefix' => 'uploads/images/profile_pictures/' // in case your db value is only the file name (no path), you can use this to prepend your path to the image src (in HTML), before it's shown to the user; ]); $this->crud->addField([ 'label' => "Poste occupé", 'type' => 'select', 'name' => 'role', // the db column for the foreign key 'entity' => 'role', // the method that defines the relationship in your Model 'attribute' => 'label', // foreign key attribute that is shown to user 'model' => "App\Models\Role", 'default' => 6,
}
protected function setupListOperation() { // TODO: remove setFromDb() and manually define Columns, maybe Filters $this->crud->setFromDb(); }
protected function setupCreateOperation() { $this->crud->setValidation(UserRequest::class);
}
protected function setupUpdateOperation() { $this->setupCreateOperation(); }
public function show($id) { //Create the Qr-code before print the user information
} }
The model
class User extends Model { use CrudTrait;*/
protected $table = 'users'; // protected $primaryKey = 'id'; // public $timestamps = false; protected $guarded = ['id']; // protected $fillable = []; // protected $hidden = []; // protected $dates = [];
/**
/**
/**
*/
public function getRoleAttribute($role){ return Role::find($role)->label; }
public function getGenderAttribute($gender){ return Gender::find($gender)->label; }
*/
/**
/**
*/
*/
*/
public function setImageAttribute($value) { $attribute_name = "image"; $disk = config('backpack.base.root_disk_name'); // or use your own disk, defined in config/filesystems.php $destination_path = "public/images/users/avatars"; // path relative to the disk above
} }`
What I expected to happen
I expected to create a user
What happened
The user is create successfully but a get this :
Call to a member function update() on string
Backpack\CRUD\app\Library\CrudPanel\CrudPanel::createRelationsForItem vendor/backpack/crud/src/app/Library/CrudPanel/Traits/Create.php:183
What I've already tried to fix it
Cancel the project 2 times and restart
Backpack, Laravel, PHP, DB version
When I run
php artisan backpack:version
the output is: