sohexaxok sohexaxok

Updating project not working

I can't find out why my project model won't be updated. I set the data and then call update on it, but it doesn't work. Can someone help me? Here is my code...
vkronlein vkronlein

Querying On Relation Column Within a Relationship

I have a SupplierThread model that has a statuses relationship like so: /** * Supplier threads have many statuses. * * @return \...
carpad88 carpad88

Get column names from table

I want to retrieve all the column names from one table in my DB, I've used this code and it works $headings = DB::connection() ->getSc...
iamlux20 iamlux20

Optimizing an audit trail display

Hi, I'm looking for ways to optimize my code if there's any. I currently have an audit trail for my item_prices and would want to only display the latest price per s...

Generating custom ID (Uuid) for Many to Many relationship pivot table

I want to use uuid as my primary key inside of pivot table (many to many relationship). But I could not found a way to catch creating hook...
GKMelbo GKMelbo

Get ID of row in pivot table

Hi, I have a pivot table called building_category with the following structure: Schema::create('building_category', function (Blueprint $table) {...
t0berius t0berius

eloquent collection question

I would like to use the following code to load the mainImage of a product, considering the custom user selection of image quality being loaded. public functi...

Get last relation rows by column

How to get last send temperature for each user through Season model!? Seasons: id, name 1|Spring 2|Winter Temperatures:id,season_id,user_id,temp,created_at 1|...
Bvanhaastrecht Bvanhaastrecht

Timestamps not updating

Hello, Somehow I got one table / model who's not updating it's timestamps. $model->attribute = 'some new value'; $model->save(); // doesnt upda...
Bvanhaastrecht Bvanhaastrecht

Mass assign with input filter

Hello, I would like to filter out input fields who not exist as a column in the table. I was thinking of something like: $asset = new \App\Models\Cmdb...
AbdulBazith AbdulBazith

Return Back from one method to another method with given date in single or array format

Guys iam working with a project Hotel Management System. i have 3 functions in mycontroller PaymentController //My routes Route::resour...
AbdulBazith AbdulBazith

groupBy in controller shows error Trying to get property 'employee' of non-object even though it has record

Guys iam working with a project, I have small a issue in groupBy function my model is EmpAttendance in my controller i did a coding...
auniik auniik

How can I get data through Eloquent filtering multiple columns

I have 3 tables. stocks, products, purchase_items. Stock Model: protected $fillable = ['product_id', 'product_code_id', 'quantity']; public function...
carpad88 carpad88

Doubt with relationships with two models

Looking for someone who can give some advice. I have a author model, and each author can have many books, but at the same time can have many contracts, (I also have a book...

Posts Overview w/ Posts per User

I created a new database with posts table for a test. Decided to add these to a separate database not part of the main database with dashboard data. This as I feel that blo...
Teleogrid Teleogrid

Model Route Binding returns Collection instead of Model

Hi guys, I'm having a simple route that should do a simple model binding but instead of an instance of a model I get a collection returned. Here is what I am doing:...
LaravelFreelancerNL LaravelFreelancerNL

ArangoDB ODM/OGM Eloquent driver?

Is anyone else interested in an Eloquent driver for ArangoDB? I'm planning to set one up in Q3 of this year. If you're willing to help with development or testing le...
polarcubs polarcubs

Given table name, get the associated Model

Is there an easy way where given the string 'users' (or any other string), returns the Model associated with that table name? Something like model_from_table_name('p...

laravel 5.7 in migration make column to nullable

i need to make column nullable i try this Schema::table('users', function (Blueprint $table) { $table->string('name')->nullable(); }): also this Schema::table(...
Crazylife Crazylife

How can i get the latest record in database based on datetime?

I have a table with value as shown below id branch_id qty datetime --- --------- ---- ----------- 1 1 2 2017-07-29 12:26:07 2...
Colin_Laws Colin_Laws

Can Eloquent accept Unix time for date fields?

I am wondering if I can configure anything on my models or environment to allow setting a date field to an integer, and having Eloquent automatically interpret this as Unix...

morphedByMany, get custom value from "pivot" table

Hi, I got this table for my morphedByMany relation. Schema::create('orderables', function (Blueprint $table) { $table->unsigned...
ravipw1801 ravipw1801

Laravel Many-to-Many

I am creating a simple place-order system, where I want to save orders in order table along with pivot item_order having additional pivot column as rate & qty. T...
CharlesK CharlesK

Laravel orderby uses

How can I use orderBy to order by a model's method? Consider the model User and the method public function fullName() { return $this->firstName...
sabat24 sabat24

Sync method for one-to-many relationship in 6.x

There is a great answer about that here Us...
Timw1985 Timw1985

What Does with(relations:'') Mean ?

I am trying to figure out the meaning of with('result')->with('check')->get(); is this joining or selecting data on these values ? The database i...
Zoefschildpad Zoefschildpad

Ordering by the results of a whereIn

As a simplified example, I have a database full of fruit and a fruit model. They have the fields 'name' and 'expiration_date'. I have an array $tropicalFruits...
AliAdams AliAdams

If I have for example defined scopeActive(), how best should I test if an Eloquent object "is Active"?

Long time lurker, first time poster - hi! This has been bugging me for a while - hopefully one of you guys will know the best way of doing this! If I have def...
premiSoft premiSoft

Seeder error

I am trying to create a seeder and I keep getting this error. Symfony\Component\Debug\Exception\FatalThrowableError : Argument 1 passed to Illuminate\Data...
mostafalaravel mostafalaravel

How to left_join in eloquent ?

First here the competence controller : $competences = Competence::with('category')->orderBy($sorting, $sortOrder); $competences = $competence...
DilipkumarC DilipkumarC

How to validate date in laravel model

I'm trying to not allow the user to save data on a specific date. Now my code will lead to user can't save data even if the user selected a specific date. How do I allow th...
pllaguno pllaguno

conditional relationship

I am not sure if something like this exists. i have searched the web and haven't find someone else trying to use something like this which might mean i am taking a wrong ap...
torriv torriv

Many queries even when using with()

So as the title says, it runs multiple queries even if i'm using with()... and i can't figure out why. i'm having this query in my controller: $this-&...
freddyheppell freddyheppell

Has Many through relation on pivot

I have an Event class which has many Positions via a pivot table (with model EventPosition). This intermediary model can also belong...

Join with sub query in eloquent

I'm trying to get the running balance from a ledger. I am able to get the results I want from this query builder. But I need to pagainate the results and I don't see that p...
Create a New Discussion Button