Closed psychonetic closed 6 years ago
Can you confirm please what’s in your attribute_entity table? That would help troubleshoot this issue..
Here you go:
see
(saving in version 0.0.3 works as expected, but in the 0.0.3 branch I am unable to get the data as mentioned in #27 )
the same problem to me !
I'm also having the same problem
please turn type to alias !
app('rinvex.attributes.attribute')->create([ 'slug' => 'size', 'name' => 'Product Size', 'type' => 'varchar', 'entities' => ['App\Models\Article'], ]);
Array ( [boolean] => Rinvex\Attributes\Models\Type\Boolean [datetime] => Rinvex\Attributes\Models\Type\Datetime [integer] => Rinvex\Attributes\Models\Type\Integer [text] => Rinvex\Attributes\Models\Type\Text [varchar] => Rinvex\Attributes\Models\Type\Varchar )
kfja85 thanks for the help, it worked!
@kfja85 Works perfectly!
Unfortunately I am still not able to get the data. Eg.
Article::with('size')->get()
Size is still null.
Did you manage this? @kfja85 @weusder
@Omranic Can you please update the documentation and include the changes?
@kfja85 @weusder Sorry for the delay, and yes that make sense now. Docs fixed to reflect the new type aliases at 102b93035355426d08f49c7176d6eb1cde9b48fb
@psychonetic I've done few tests again now & everything seems to be working fine. What you need to make sure of is the following:
attributes
table has your new fieldattribute_entity
table has relation between your new field and your entityattribute_varchar_values
or any other values table (depending on your attribute type has your entity valueIf all these three tables has the correct info, then you should retrieve the value. If not, then please screenshot or dump the three tables here and I'll try to go through it & see what's wrong..
@Omranic That sounds good!
Yeah, I show you.
Attributes table:
Attributes entity table:
Attributes Varchar Table:
So everything should be fine in my opinion.
Seems to be fine, and I've reproduced the same data as yours & it worked like a charm. One last thing, if you've cache enabled please disable caching & check again and let me know if that makes any difference. It's good to flush app cache for the sake of troubleshooting..
@Omranic I tried to clean the cache, but no change. Any further idea? Maybe I will try to create a project later, only with your package and just laravel. Otherwise I don't know.
@kfja85 @weusder Do you the same problem or is it working as expected?
I assume that your App\Models\Article
model already using Rinvex\Attributes\Traits\Attributable
trait, and you're retrieving it normally like:
$article = \App\Models\Article::with(['size'])->find(1);
dd($article->size);
If that's what you're doing and you still get nothing, then I'm not sure it's something related to this package. It's working with or without any other packages without a problem, I replicated the same setup & even same table data and can't reproduce your issue. Make sure there's no other size attribute used by the same model or attached by any other package in someway, otherwise please try to reproduce in a new project and mention the steps on how can we reproduce the issue in order to troubleshoot it.
For now I'll close this issue as it's not confirmed as an issue, but feel free to open it again or open a new one for further assistance.
Hello,
if I try to create an entity, I get the following error:
Class name must be a valid object or a string
The error occurs inside Illuminate/Database/Eloquent/Concerns/HasRelationships at:
My code:
//attribute creation
//Article (yes, it uses the attributableTrait)
Any idea? Laravel version is 5.5 and used attributes version is dev-develop 8bce023.