Closed kis60 closed 3 years ago
Did you create & execute a migration for your Poll
model? If no, please do so. This is related to your Poll
model, not this package. For more info check:
Did you create & execute a migration for your Polls model?
Yes, I did. But, while doing
$p = Poll::where('link', 'AAA')->first();
("Rinvex Attributes tries to do everything in the same way Eloquent would normally do" !) I got QueryException "Column not found: 1054 Unknown column 'link' in 'where clause'". What's wrong?
Can you execute the following code and tell me what's the output:
app('rinvex.attributes.attribute')->where('slug', 'link')->get();
Also can you confirm what's your fully qualified Poll
model namespace.
Hello. Thanks for answer.
Tuesday, June 15, 2021, 11:11:22 AM, you wrote:
Can you execute the following code and tell me what's the output:
app('rinvex.attributes.attribute')->where('slug', 'link')->get();
I got object of type \Illuminate\Database\Eloquent\Collection. Field items is array with 1 element.Also can you confirm what's your fully qualified
Poll
model namespace. namespace App\Models;
use Illuminate\Database\Eloquent\Model; use Rinvex\Attributes\Traits\Attributable;
class Poll extends Model { use Attributable;
protected $table ='polls';
protected $fillable = ['link'];
}
Query SELECT * FROM attributes; returns 1 link {"en": "Link"} (null) 1 (null) varchar 0 0 (null) 10.06.2021 17:57:07 10.06.2021 17:57:07
-- Best regards, Yuri D.Kislitsky @.***
-- Это сообщение проверено на вирусы антивирусом Avast. https://www.avast.com/antivirus
I was a little confused Why should the Product table be created and according to the document, when I want to create a custom attribute price, it gives an error that the price column is not available !!!
@vahidalvandi What product table? 🙂
hi @Omranic product table in https://github.com/rinvex/laravel-attributes#assigning-values and according @kis60 poll table . please show a demo
This is just an example, you need to create that table yourself. That example could be Product
or Article
or anything else, that's your business logic and not within the scope of this package to cover.
i need this senario do it work ?
i have lead table with three columns (id , name , lname) . i want admin can add multi cloumn like mobile , email without change table .
Yes it works, but you can achieve that through different ways. You can use this EAV package, or use a more simple approach the get the job done as well https://github.com/spatie/laravel-schemaless-attributes
That's why I mentioned previously if you don't know EAV and want that model specifically, you probably don't need it at all, and probably there's a better more simple solution to solve your challenge.
My model class:
I have registered type and entity
I have successfully created attribute:
app('rinvex.attributes.attribute')->create(['slug' => 'link', 'type' => 'varchar', 'name' => 'Link', 'entities' => ['App\Models\Poll']]);
But when adding an entity
I get the error
Base table or view not found: 1146 Table 'eav.polls' doesn't exist (SQL: insert into 'polls' ('updated_at', 'created_at') values (2021-06-10 19:16:50, 2021-06-10 19:16:50))
What's wrong? Thanks in advance.