Questions tagged as 'laravel-eloquent'

1
answer

Eloquent select total query

I'm trying to group to bring totals into my query that is in mysql SELECT COUNT(*) as total ,e.descricao FROM pedido_cliente p INNER JOIN estabelecimentos e on e.id = p.estabelecimento_id GROUP BY p.estabelecimento_id,descricao...
asked by 07.12.2018 / 18:22
1
answer

SQL with associated data in Laravel?

I have the following tables listed below Products id product value Validity Queries id user_id Product_Consults id query_id product_id Whenever a user performs a query, the history in the consultas...
asked by 18.08.2018 / 14:42
1
answer

How to return reregistered records between tables in laravel

I have 2 city and state tables I own the parana state and would like to know how to return all cities related to Parana state in a simple way without having to make a loop of repetition Type $estados = App/Estado::all(); $cidades = App/Cida...
asked by 20.11.2018 / 12:18
1
answer

Invalid handle returned - Laravel connection with SQL Server

I was developing an application with Laravel 5.5 with a Mysql database. Everything was working normally, however, now the database has been modified to SQL Server. When I run the test, it returns the error "Invalid handle returned." Searc...
asked by 21.09.2017 / 15:35
1
answer

Laravel - Relationship ManyToMany extra columns

I have the following scenario in a database: Tables: User id, name email Company id name UserCompany userid business_id start_date data_termino In this scenario, I need to bring the information...
asked by 16.08.2017 / 18:32
2
answers

Pass string to uppercase - laravel

Good afternoon. I have the following code that perfectly saves. public function store(Request $request) { $this->validate($request, [ 'servidor' => 'required|unique:servidors|max:255', // 'dtprotocolo' => 'date|date...
asked by 08.11.2017 / 19:25
2
answers

Laravel / Eloquent - Undefined variable: idRequest

I have two queries looking at the model. The first one is working normally: $pedidos = Pedido:: orwhere(function($query){ $query->where('user_id', $_SESSION['idUsuario'])...
asked by 20.10.2017 / 19:27
1
answer

Optimize queries with leftJoin Laravel?

I have linked tables and when I need to access the information I recuse the query : DB::table('paciente AS pac') ->leftJoin('pessoa AS p', 'p.id', '=', 'pac.id_pessoa') ->select('p.nome, pac.ficha') ->where('pa...
asked by 26.05.2017 / 16:26
1
answer

Doubt Laravel SQL Queries?

I'm starting with SQL of Laravel I looked a lot more I did not get a response of how to AND after where , follow sample code to implement AND . SQL: UPDATE contas SET valor_titulo = 0, WHERE id_contrato = 2...
asked by 22.03.2017 / 20:41
1
answer

How to change the default name of an eloquent column

I'm in a project that is in production, and by default when we use a foreign key in eloquent we follow the following rule "user_id" for example to store the user id. Only in the database that I'm working with, they put this field as " id_u...
asked by 20.06.2017 / 14:01