JohnBeales JohnBeales
3

Three Way Relationship or Relationship with a Relationship?

I'm puzzling over how to set up this relationship in Laravel, (I'm converting a legacy app): I have Repair Shops, which provide different types of repairs, on differ...
princeoo7 princeoo7
10

Need Eloquent Relationship help.

Hello Every one. I am new to eloquent relationship and i am sucked with following questions. i have three tables. article. gallery. us...
SangminKim SangminKim
2

Grouping by 15 days( 1 ~ 15 ) / ( 16 ~ end of month ).

Hi everyone, I have a query that groups billing information by month. However, I'd like to tweak it so that the query retrieves billing information by 15 days - i.e....
zaster zaster
3

Get several rows using the foreign key

How can i select several po_item rows with several cost_item_id (foreign key of po_items table) $cost_items-&...
konrms konrms
12

How to implement oracle query to select from different tables in laravel

I'm trying to select distinct from different tables in laravel. In oracle I have implemented successfully the query and works. Now I'm trying to "translate" it in...
yoeriboven yoeriboven
0

Which relationship would you choose?

My app functions kind of like Twitter. A User would follow Profiles which have Posts. A user doesn't have posts, profiles do. The User and the Profiles are in a Many...
bufferoverflow bufferoverflow
1

Multiple models query and order optimization

I'm getting all rows from 3 models and then concat in the same collection and order them by creation date. I'm thinking in a way to optimize, any ideas?...
jhutto jhutto
11

Cleaner Controllers

I recently watched the Laravel 5.7 From Scratch - Cleaner Controllers and Mass Assignment Concerns Video And I started working on cleaning up my controllers. T...
Eloquent
11
123
hmiggels hmiggels
1

Eloquent GroupBy unexpected results

Hello, I'm trying to group records based on a column 'role_id' in the products table. But I also like to use eager loading / with() - I must be missing something but...
megaman megaman
2

update some related models of some models

I need to update a load of models The models i need to update must be related to a different model which must be filtered by a where clause The models being updated...
bwrigley bwrigley
3

'Undefined index' since 5.7 upgrade

Hi There, Just moved up to 5.7 from 5.6 today and seem to have hit an issue in Eloquent. We have a model called Profile and another called...
kshitizmittal kshitizmittal
1

Raw Query To Eloquent Query builer

I want to convert this raw query to eloquent, but it seems to be complex, please help me out. select one.emp_id,one.date,one.punch_in,one.punch_out,two.type_...
DPlachkov DPlachkov
1

Turning Many to Many relationship - to - hasMany - as comma separated values

Hello guys. I have this problem with a relationship i want to save differently. I have Shipments and Errors tables(models). Now we have some validation and if a ship...

Workaround to avoid using 'polymorphism'?

I read in the book SQL Antipatterns several solutions to the anti-pattern of polymorphic relationships. (The point being the key is on the wrong side of the relationship -...
kylevorster kylevorster
3

Original data on belongsToMany

I'm trying to get the original data on a belongsToMany relationship, I've tried everything I can think of but I just can not get it to work. Anyone got some advice?...
tanveerkhanwd tanveerkhanwd
1

How to use json encode on following data

( [_method] => PATCH [_token] => pp7bjIqWRL8hatrNyh4ZPtNeb8i6lpjD51QCzFMw [permission] => Array ( [A...
vinubangs vinubangs
1

Laravel Join 3 tables , one data from first two table and multiple row from third table

I have 3 tables. 1st table- journals id | journal_name 6 | xyz journal 7 | abc journal 2nd table- volumes id | journal...
ashwini1987 ashwini1987
1

Jenssegers/Mongodb

Hello, I have dump data from MySQL to Mongo DB. Now I want a data between the two dates and recodes store as timestamps. Please suggest how to write the query in laravel....
zarcoder zarcoder
8

One to Many Relationship Logic

I'm learning php and laravel. I'm doing a crud test for a company and if I pass I can be considered for joining the dev team. One of the requirements of the crud test is th...
Vic-Gutt Vic-Gutt
9

Making a Laravel 5.4 query on a JSON field containing a JSON array

Hi everyone, i'm trying to query a JSON field containing an array of values. For exemple sake we'll name the table "User" and the field "...
rb224315 rb224315
1

Details table is deprecated; data is now in its own column on master

I have a system from a third party which was recently upgraded. Prior to the upgrade it used master and details tables to store configuration. Post-upgrade, the details d...
trevorpan trevorpan
26

don't show form if auth()->user has submitted form

Hi, this form shows how many interested bidders there are for a given job. After a user_id has submitted interest to bid, the blade takes away the possibility...
Eloquent
26
209
corean corean
2

Adding a subquery to an eloquent query

I want to add a field to the result set of an eloquent query that its value is provided by a subquery. In other words I want the returned eloquent models have an ext...
midwestdev midwestdev
4

Reference two columns on another table or reference the id?

I have a parent called formula_items that will have many ingredient, and it has a parent that will have many formulas I don't want to have to add ingredients each time so...
shone83 shone83
4

I can't get property name from belongsToMany method

When I try to get name from tags I get error: "Property [name] does not exist on this collection instance. (View: C:\xampp\htdocs\wink\resources\views\b...
ravipw1801 ravipw1801
2

Laravel Relation One to Many (Polymorphic)

Am making a laravel project, Admins & Executives an assign jobs to designers. Below is the Admin model: Admin.php public function jobs() {...
fikri1510 fikri1510
1

One to one relationship based on imported existing data

Suppose I have customized User and Profile tables. Profile table is based on imported existing data. They are connected with one to one relationship. How can I deal...
davidifranco davidifranco
10

Get Model Only if All Related Models Have

Whats the correct way to query a model only if ALL the related models fit a certain criteria.. Model::whereHas('RelatedModel', function ($query) { $query...
Eloquent
10
132
Simon_G Simon_G
2

Pluck nested values from Collection

I'm trying to pluck the value from a nested relationship within a collection. But I can't seem to pluck the nested column values: class...
rb224315 rb224315
2

"Overriding" data retrieval methods for a model (v5.2)

Due to a change in a 3rd party database which cannot be modified, for every call to get(), first(), or any other data retrieval methods on one of my existing models I need...

Pluck value from nested relationship

Hello everyone I have been searching through the documentation, as I am convinced there is an Eloquent way of doing what I am trying to do but can't seem to find it....
PhoeniX5 PhoeniX5
12

Laravel transfer data in Mysql

I need to transfer data from mysql table to another mysql table, here is my code: function Commande(Request $request) { $pn = $request->input('id'); $pdr = Panier...
Eloquent
12
139
Sinres Sinres
5

Laravel eloquent where date is equal or smaller than DateTime

Hello Guys! How I can take date where date is equal or smaller than date time? This is my code: $current_date = Carbon::now(); $date = Carbon::...
pawan94 pawan94
2

Fetch data from multiple tables

I have four table 1) batch table 2) student table 3) batch_student table (pivot table) 4) student_attendance. batch : id, name student : id, name...
Create a New Discussion Button