Skip to content
Advertisement

Tag: eloquent

fetch related records between 3 model

I have few products in 3 category (for example), and each product has a brand. I want to show brands which related to products in a specific category. Models: –product –brand –category relations: category has many products brand has many products How can I do that? Answer Considering you have 3 models with relationships like : Brand Model : Product

How to get plain text from html in laravel model?

I’ve a database column named description in which i’ve saved input from tinymce editor. data is something like this, I can easily display the data in view with following, But, I need some processing to get 30 words from text with following code in model, and I’m currently geting empty when I call shortDescription function. Is there any way to

Laravel 5.5 BelongsToMany with pivot conditions

I have three models, Clinic, Department and ClinicDepartment and has belongsToMany relation called departments from Clinic to Department using ClinicDepartment’s table as pivot table, but when i using this relation, scopes from ClinicDepartment not aplying in query. I decided to make Pivot model calling ClinicDepartmentPivotand apply those scopes to Pivot, but no luck. Clinic model: Department Model: ClinicDepartmentPivot Model: ActiveOnlyScope:

Laravel Nova Self-referential Relationship

In Laravel, if I want to create a self-referential relationship I can do the following: How can I make a Laravel Nova resource display this connection? Answer You can achieve what you want like this: This will allow to choose a parent post when you create or update a post. When you are in the detail page of a post,

Advertisement