Category "eloquent"

How to use regex or any other operator with whereIn clause

Is there any way we can use operator or regex as we normally do with the whereIn() clause. I want to use something like this $query->whereIN(name,'like','%te

renameColumn migration fails for existing column with columns does not exist error

I get the error Doctrine\DBAL\Schema\SchemaException : There is no column with name 'price' on table 'class_rooms'. while running migration to rename the price

Get all the products which are inside parent Category and child categories in Laravel with the help of relation

I have category and product table as follows: Categories: id | name | slug | parent_id Products : id | brand_id | name | slug | price | desc P

Laravel Polymorphism for different content types (Multisite)

I started to develop a little Content Management System for two languages (de, en) that starts to grow bigger. In that context, I have Posts and Pages (a bit li

Laravel 8 eloquent query delete

How to delete the aircon in database when there is no any data. Order and Aircon are many to many relationship. $orders = Order::with('aircons', 'user')

Laravel eloquent query with filter "where ILIKE" does not match with any value with accent saved in my Postgre database (encoded in UTF8)

I have a Laravel 5.8 app. It works with a Postgres Database encoded with UTF8. I have a query for my users table, so i made my query as: $users = User::where

Sync Records With Default Values in Pivot Tables, Call to undefined method syncWithPivotDefaults()

I just upgraded laravel 7 to laravel 8.30.1 and I am trying to add the default value of pivot column object_model of term_relationships table using the newly in

how to use whereHas in laravel

I am new to laravel, I need to create a query for the db, $query = Deal::query(); I want to use the wherehas operator. this is my code that is worked. else if

One eloquent query with whereIn clause with more than 3000 elements works but another one with the same elements and format doesn't

Hello and thank you beforehand for your help. I've been hitting my head against a wall with this problem for a few days now so decided to ask here. I have two q

Laravel. Json column with cast as array are returning as a string when using JOIN in query

Laravel 8. I have two tables(models) 'employees' and 'positions'. In a model 'employees' I have a casts: protected $casts = [ 'academic_post' => 'array'

Laravel Model save() & update() Not Saving

Laravel 5.7 Hello I have been looking through stack overflow and have tried many possible answers and have come to no conclusions. I am updating a simple inte

Laravel empty pagination data

My query from Laravel Builder toSql() function. select `dispatcher_leads`.*, (select CASE WHEN lead_positions.order_type = 'shift' THEN DATE_ADD(lead_positions

laravel get error of Call to a member function prepare() on null

In Laravel I have got this error, while inserting a record in my MongoDB database. Call to a member function prepare() on null namespace App\Http\Controllers;

How to optionally call mutator in lumen

i use mutator in my model to encrypt id: public function getIdAttribute($value) { return encrypt($value); } but I want the default value to be the original

How to update the timeout field in the attendance table for a given user_id, logdate and status using if else statement?

I have been trying to update the timeout for a given user_id, logdate, and status but my update statement is not working or may be my other if else are not corr

Laravel having column name in where clause static method

Recently I just realized that Laravel generates a static method with column name when joined in a where clause using camel case example $user = User::whereN

Laravel Eloquent relationships with 3 Table

Laravel 3 Table table_user id name table_barang id iduser name statusbarang_id table_statusbarang id name My code UserModels: public function BarangModels()

Laravel SQL query midnight time not showing

I am making a schedule display system and it shows the schedules of ferries. my problem is if I dont put midnight time in order then query skips midnight time a

Laravel mongodb where array field contains value

I use mongodb and mysql together with Laravel. Fields table in mysql database can have more options in mysql database. fields table in mysql: id, name options

How to order by eager loaded relationship in Laravel 5.5?

The code below works perfectly and displays all products with discounts in JSON Format for my API. But I want the result ordered by id in the discounts table. S