pings12 pings12
1

Method after data is loaded after model is initialized.

Say i'm fetching a user on my User.php $user = User::find(1) I want to call a method automatically after the $user...
TacitReturn TacitReturn
5

Return one value from similar fields

Hi everyone, I'm new to the discussion form, in advance my apologies if this question has been asked already. I've been searching around for a bit and haven't found any sol...
Rretzko Rretzko
4

Call to undefined method stdClass::video()

Hi - I need some better eyes on this. I have code working on one view, but when failing on a second view. The Controller looks correct to me and I get the right results o...
raulmercadox raulmercadox
3

Query with filter on child tables

I have these tables: orders ---------- id (PK) stage_id (FK) stages --------- id (PK) phase I'd like to query the orders which associated s...
donkfather donkfather
13

Insert multiple records in one query

Hello again, :) I have a list of objects ( same object ) and I would like to insert them in the database at once. I have tried with createMany but this method I thin...
Eloquent
13
20786
jomasjoao jomasjoao
2

Laravel-echo frontEnd script not working

I am using Laravel-echo and pusher to receive notifications in real time, my pusher is receiving messages, however my JavaScript code in FrontEnd is not receiving notificat...
GodziLaravel GodziLaravel
2

How to concatenate two two values from the same eloquent result ?

Hello here the result of my request : $searchableColumn = SearchableColumn::where('id','=',$id) ->with('searchableTable')...

Eager loading not working with particular UUID

I’ve been stuck on the weirdest problem for half a day now. I am using UUID(4) as primary keys on my models. I’ve stumbled on a UUID that seemingly breaks eager loading...
mskhoshnazar mskhoshnazar
4

Belongs to many through

I wonder why this is not a part of laravel. Let's say we have projects and categories that belongToMany each other. That's eas...
fidanym fidanym
2

Include events with “touching” start/end times in query

I am running a Laravel 6 app using MongoDB through Jenssegers MongoDB plugin. So far I have not had to write a raw mongo query and I hope I won't have to for this one too,...
rsarvarov rsarvarov
4

Get "dirty" attributes of model (even if no changes)

I know about getDirty() method, that gives me properties that been changed (before save()). But what if I want to know properties that haven't cha...
Utchin Utchin
7

Query with where + where or + where in not working

I am having some trouble getting this to respond correctly: $teams = Team::where('options->stage', 'Subscribed')->get()->pluck('id')->toArray();...
tykus replied
Solved

How to access pdf file

Hi, I store in my database some pdf files. But when I want to display them in my blade I cannot see them. And when I look at the inspector, in the src=' ' it says &q...
t0berius t0berius
6

eloquent insert model with three relations

Inserting a new order into the database involves a few relations: public function seller(){ return $this->belongsTo('App\User', 'seller_...
rreyes1979 rreyes1979
3

LockWaitTimeoutException for transaction retry

Hi. Is there anything like a "LockWaitTimeoutException" that can be caught to retry transactions? As it is right now, I am using the following code to identify lo...
robdevel robdevel
3

Laravel8 - Eloquent query builder: how add a raw query?

Hi to all, I cannot write a Query Builder with a raw query inside. I need to use the Query Builder 'cause I'm paginating and sorting the results via scoped query. Is...
a4ashraf replied
Solved
armancs armancs
4

Non-static method Illuminate\Database\Eloquent\Model::update() should not be called statically

Got this error when trying to update eloquent data. Controller : public function update(Request $request, $id) { Invoices::updat...
Sinnbeck replied
Solved
Eloquent
4
6735
NiloLeon NiloLeon
4

Laravel Eloquent limit and distinct

Hi, I extract this datas with eloquent $refunds = Refunds::whereNull('num_pre') ->where('status_ref', '>', 4) ->orderBy('claims_id', 'ASC')...
durairaj durairaj
11

How to get data from multiple table interrelated with each other

user- table id name email status 1 durai [email protected] active orders -table id user_id order_no total 10 1 #74749 250 order_items - table id o...
Eloquent
11
247
coder72 coder72
5

How to make users column empty from SQL Statement ?

Like yesterday, This is my users table and i want to make coursable_id and coursable_type empty ? id | name | email | coursable_id | coureable...
t0berius t0berius
4

laravel insert relations based on two models

Using the following model Product: public function favouriteUsers() { return $this->belongsToMany('App\User', 'favourite_products'); }...
Mqandeel Mqandeel
2

get first 10 tags

$blog= Blog::where('slug',$fslug)->with('tags)->firstOrFail(); this will return the spacific blog with all related tags how to return just...
devondahon devondahon
2

How to use multiple oWhereRaw clause with an array of search terms ?

How to have multiple orWhereRaw clause, one for each element of my array: $array = ['foo', 'bar', 'hello', 'world']; re...
coder72 coder72
4

How to delete users from SQL Statement

My users database look like this I want to cleany database data so i am cleaning from localhost. id | name | email | coursable_id | coureable_...
coder72 replied
Solved
devondahon devondahon
5

orWhere with array of search values and wildcard

I have an array of search values set like this: $string = 'foo bar hello world'; $array = explode(' ', $string); $array = array_map(fn ($value) => '%' . $...
InToSSH InToSSH
6

Teams-Members-Users - help with DB structure

Hello, I am building an app for teams and their members and I am ripping my hair out trying to figure out the structure to be best and simplest to use with Eloquent. Also I...
webfuelcode webfuelcode
0

Using cviebrock sluggable with validator

I am using cviebrock/eloquent-sluggable slug package for my project and want to use it with validating data. Tell me how to use it... Where and how to u...

query on created_at with carbon

I have this query Community::where('created_at', Carbon::now()->subDays(3)->toDateString()) and in db i have this raw "...
Snapey replied
Solved

get 50% percent of gender

i have user table with gender i need to pick up 20 users half of them female i did that private function getUser() { $female_users...
mkshingrakhiya mkshingrakhiya
4

Query performance degraded after converting raw queries to Eloquent ones, How do I speed it up?

I had loads of raw SQL queries on a single page, 110 to be exact. It took nearly 1.2s to get data from all of them. Now, I managed to combine them all and got all the neede...

Multiple Paginations on one page

Hi! I'm currently looking for a way to have multiple paginations on a single page, with they are interfering with each other. How can I do that? Best Regards, Foks...
Foks replied
Solved
Eloquent
11
208
msslgomez msslgomez
6

WhereHas returns unexpected item

I'm trying to get all products for a store where the inventory is greater than 0, but it's returning a product that has -1 inventory for some reason. $produc...
Gavmrz Gavmrz
1

WhereHas relationship latest()

I have a model Job with relationship lastAction. public function lastAction() { return $this->hasOne(\App\Task::cl...
bljdavidson bljdavidson
7

Updating Column to allow nullable but can't because of type enum

Hi all, I am trying to update a field on my table to allow it to be nullable. public function up() { Schema::table('videos',...
phpguru phpguru
2

[PDOException] SQLSTATE[HY000] [2002] No such file or directory

I've been using Docker for Windows with Laravel 5.3 + Spark for nearly a year. Now all of a sudden, something has changed in my environment and I cannot figure out what. Wh...
Eloquent
2
3018
Create a New Discussion Button