Coder Social home page Coder Social logo

Comments (12)

staudenmeir avatar staudenmeir commented on June 14, 2024 2

There is an issue you should fix: Both attribute and relationship are named parameters. This is problematic because it prevents you from accessing the relationship with $vacancy->parameters.

from eloquent-json-relations.

staudenmeir avatar staudenmeir commented on June 14, 2024

What query are you executing to get this result? What are the JobVacancy's attributes?

from eloquent-json-relations.

DmitrySkibitsky avatar DmitrySkibitsky commented on June 14, 2024

What query are you executing to get this result? What are the JobVacancy's attributes?
JobVacancy's attributes:

protected $fillable = [
        'price',
        'price_end',
        'shortcuts',
        'parameter_heading_id',
        'parameter_location_id',
        'parameters',
        'status',
        'archive',
    ];

    protected $casts = [
        'price' => 'float',
        'price_end' => 'float',
        'shortcuts' => 'array',
        'parameter_heading_id' => 'integer',
        'parameter_location_id' => 'integer',
        'archive' => 'integer',
        'parameters' => 'json',
        'status' => 'integer',
    ];

query method

     /**
     * GetModelsForPublic.
     *
     * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
     */
    public function getModelsForPublic()
    {
        $query = $this->model::query();

        $query->searchVacancy();
        $query->sortVacancy();
        $query->with('parameters');

        return $query->where('status', true)
            ->paginate(8);
    }

dump

$vacancies = $this->job_vacancy_repository->getModelsForPublic();
dd($vacancies->first());

from eloquent-json-relations.

staudenmeir avatar staudenmeir commented on June 14, 2024

What's the result of dd($vacancies->first()->getAttributes());?

from eloquent-json-relations.

DmitrySkibitsky avatar DmitrySkibitsky commented on June 14, 2024

What's the result of dd($vacancies->first()->getAttributes());?

array:12 [▼
  "id" => 1
  "price" => 50.0
  "price_end" => 50.0
  "shortcuts" => "[{"value":1}]"
  "parameter_heading_id" => 3
  "parameter_location_id" => 17
  "parameters" => "[{"id":17},{"id":22},{"id":13},{"id":9},{"id":6}]"
  "status" => 1
  "created_at" => "2020-05-08 11:46:00"
  "updated_at" => "2020-05-15 22:07:42"
  "sorting_order" => 999
  "archive" => 0
]

from eloquent-json-relations.

staudenmeir avatar staudenmeir commented on June 14, 2024

Thanks, I'll look into it.

from eloquent-json-relations.

DmitrySkibitsky avatar DmitrySkibitsky commented on June 14, 2024

What's the result of dd($vacancies->first()->getAttributes());?

Laravel Framework 6.18.14

  "require": {
    "php": "^7.2",
    "ext-gd": "*",
    "ext-json": "*",
    "artesaos/seotools": "^0.17.2",
    "astrotomic/laravel-translatable": "^11.7",
    "fideloper/proxy": "^4.0",
    "fruitcake/laravel-cors": "2.0.x-dev",
    "itsgoingd/clockwork": "^4.0",
    "jenssegers/agent": "^2.6",
    "kalnoy/nestedset": "^5.0",
    "laravel/framework": "^6.2",
    "laravel/tinker": "^2.0",
    "mcamara/laravel-localization": "^1.5",
    "pherum/laravel-bbcode": "^1.0",
    "prettus/l5-repository": "^2.6",
    "staudenmeir/eloquent-json-relations": "^1.1",
    "tymon/jwt-auth": "^1.0.0-rc.5"
  },

The Parameter class has trait NodeTrait, but it is also impossible to get data without it. The only thing that changes after I remove this trait

before

"parameters" => Kalnoy\Nestedset\Collection {#1815 ▼
      #items: []
    }

after

 "parameters" => Illuminate\Database\Eloquent\Collection {#1809 ▼
      #items: []
    }

from eloquent-json-relations.

DmitrySkibitsky avatar DmitrySkibitsky commented on June 14, 2024

Thanks, I'll look into it.

Okay, thanks.

from eloquent-json-relations.

staudenmeir avatar staudenmeir commented on June 14, 2024

I haven't been able to reproduce the issue so far.

Can you log the executed queries with \DB::enableQueryLog(); [...] dd(\DB::getQueryLog()); or a package like https://github.com/barryvdh/laravel-debugbar?

from eloquent-json-relations.

DmitrySkibitsky avatar DmitrySkibitsky commented on June 14, 2024

There is an issue you should fix: Both attribute and relationship are named parameters. This is problematic because it prevents you from accessing the relationship with $vacancy->parameters.

Aww... I hadn't thought of that. My apologies. I'll check later, because I probably won't be working today.

from eloquent-json-relations.

DmitrySkibitsky avatar DmitrySkibitsky commented on June 14, 2024

There is an issue you should fix: Both attribute and relationship are named parameters. This is problematic because it prevents you from accessing the relationship with $vacancy->parameters.

Good time of day. I found a problem that caused the package to not work. Despite the fact that the data was correct after the selection in the collection the model had mutations that I removed and everything started working. I'm sorry to have disturbed you.
Аннотация 2020-05-17 105646444
But the name will need to be changed in any case, as it is misleading.

from eloquent-json-relations.

staudenmeir avatar staudenmeir commented on June 14, 2024

No worries, I'm glad you could solve it.

from eloquent-json-relations.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.