Skip to main content

All Questions

Tagged with
0 votes
2 answers
30 views

Polymorphic many-to-many relationship model property doesn't return collection but ->get() does

I have two models Product and ProductType which both have a relationship with the Usp model. I have set up the models like this. class Product extends Model { use HasFactory, SoftDeletes; ...
The Stompiest's user avatar
0 votes
0 answers
37 views

Laravel Polymorphic Relation Doesn't Get the Type Automatically

I have 3 tables; receipts, obsolescence, and stock. Stock can have receipt and obsolescence. recipt table: id: integer obsolescence table: id: int stock table: id: int transaction_id: int ...
Newbie's user avatar
  • 21
0 votes
1 answer
132 views

How to implement One To Many (Polymorphic) in symfony

Hi I have three entities User, Admin, Log Both the admin and user have many logs. Each log has one owner might be Usermight be Admin. In this case, I was searching for a similar system as Laravel ...
Mojtaba Nematpour's user avatar
0 votes
0 answers
465 views

How to Filter Relationships with Null 'Type' and Polymorphic Many-to-Many in Filament's ComponentRelationManager

I have a challenging question for today. I have these two relationships. In Filament's ComponentRelationManager, I have the "attach" action. However, before becoming relationships, the sub-...
Davide Cavallini's user avatar
0 votes
1 answer
32 views

Converting a polymorphic database row into the corresponding Eloquent model in Laravel

I might be using the wrong terminology here, which I apologise for in advance! I've got an existing database table which looks like.. Events: id type title date 1 PARTY Summer party 2023-08-01 2 ...
owenmelbz's user avatar
  • 6,428
0 votes
1 answer
67 views

can't get morphable property on laravel blade

I have a Comment and Post models as below: Comment model relation: public function commentable(): MorphTo { return $this->morphTo(); } Post model relation: public function ...
Milad's user avatar
  • 51
0 votes
1 answer
59 views

I have problems using Polymorphic Relationships in Laravel 9.x

I have 5 tables named Users, Chats, Buletins, Hartas, and Owners. All of these tables has many-to-many relationship with another table named Medias, via a pivot table named Mediables. I need to use ...
Khairil Azri's user avatar
2 votes
1 answer
68 views

OOP | Is there a way to call an inherited method using the parent sub-methods?

Here is a PHP code snippet to illustrate my question: <?php class A { protected function subMethod() { return "A::subMethod"; } public function mainMethod(){ ...
Alaa Mahmoud's user avatar
0 votes
1 answer
120 views

how to implement polymorphism using abstract class for getting, saving and deleting three different product types in php

how can I implement polymorphism using an abstract class for handling product saving, deleting, and showing for three different product types? there are three product types: DVD, Furniture, and Book ...
pedram's user avatar
  • 201
0 votes
0 answers
49 views

How to avoid conditional statements using polymorphism?

Product class is the abstract class and three child classes extends to it. createProduct method is in the ProductController class, it is a common method to save the data in the database. class ...
sajid ahamed's user avatar
0 votes
1 answer
39 views

How to fetch polymorphic relation matching data?

I have three tables Jobseekers, Preferences and Industries. Preferences table is foreign table of Jobseeker and Preferences is connected with Industries table with polymorphic relation. Table ...
Coder365's user avatar
0 votes
1 answer
379 views

Laravel 9 laravel associate polymorphic relations bookmarks

I have this Bookmark model public function bookmarkable() { return $this->morphTo(); } public function user() { return $this->belongsTo(User::class); } and in my User model public ...
Andre's user avatar
  • 638
0 votes
1 answer
357 views

Return only specific columns of a polymorphic relationship? Laravel

is there any way that I can only get specific columns back of my polymorphic relationship? I want to make an Api Call to retrieve a Customer but I dont want to retrieve all the data of the User just ...
RobinBang's user avatar
0 votes
1 answer
450 views

MorphMany relationship returning empty array in laravel 8

I'm trying to return the product data with image with Morph relationship I can save the data, however when I'm retrieving it, the images field has empty value. Product Model: protected $fillable=['...
Infinite Button's user avatar
-2 votes
1 answer
115 views

Using Polymorphism instead of conditional statements PHP

I am practicing OOP concept in PHP. I’m developing a site to add products into mysql database. Every product has its product_id, name, price and product_type. 3 types of products should be inserted (...
Dinesh's user avatar
  • 1

15 30 50 per page
1
2 3 4 5
15