rinvex / laravel-attributes

⚠️ [ABANDONED] Rinvex Attributable is a robust, intelligent, and integrated Entity-Attribute-Value model (EAV) implementation for Laravel Eloquent, with powerful underlying for managing entity attributes implicitly as relations with ease. It utilizes the power of Laravel Eloquent, with smooth and seamless integration.
MIT License
433 stars 104 forks source link

Class 'varchar' not found #155

Closed dani7115 closed 2 years ago

dani7115 commented 3 years ago

Hi, Following your documentation. I am trying to do this one.

// Get all attribute values of type varchar $values = $attribute->values('varchar')->get();

But it gives me error " Class 'varchar' not found "

As I've already done some research and tried to register attributes types in my APP SERVICE PROVIDER .

public function register()
{
  //  Log::info('message here');
    Attribute::typeMap([
        'text' =>\Rinvex\Attributes\Models\Type\Text::class,
        'boolean' =>\Rinvex\Attributes\Models\Type\Boolean::class,
        'integer' =>\Rinvex\Attributes\Models\Type\Integer::class,
        'varchar' =>\Rinvex\Attributes\Models\Type\Varchar::class,
        'datetime' =>\Rinvex\Attributes\Models\Type\Datetime::class
    ]);
}

Which is fine. But still this error is appearing Also, i have confirmed that the FILE exists in my Rinvex vendor directory.

Can u let me know how I can fix it for me?

paligiannis commented 3 years ago

have you published the vendor?

dani7115 commented 3 years ago

Yes I did. Even I had doubt maybe I did something wrong. So I did this again 3 times from the start. But still wasn't able to fix this.

paligiannis commented 3 years ago

Please show the import statement on the top of the file

dani7115 commented 3 years ago

These are the imports for the controller that i'm using for testing


<?php

namespace App\Http\Controllers;
use App\Models\Company;
use App\Models\Product;
use Illuminate\Http\Request;

And these are for SERVICE APP PROVIDER

namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Rinvex\Attributes\Models\Attribute;
paligiannis commented 3 years ago

try to import them as

use \Rinvex\Attributes\Models\Type\Varchar as Varchar1

and then use it in your code

Omranic commented 2 years ago

Sorry about that, I pushed a fix the docs. The correct code should be as follows: $values = $attribute->values(\Rinvex\Attributes\Models\Type\Varchar::class)->get();