Questions tagged as 'eloquent'

2
answers

Laravel | Id generated automatically

I am doing a news system and I want my url in the following way: http://web.com/noticias/{id_generado}/ The {id_generado} is an id that I generate using the str_random(10) function. The problem of the matter is: What happen...
asked by 08.09.2017 / 01:00
1
answer

Laravel 5.1 -Eager Loader gets me the last element of sub-fix

This is the code .. public function create() { $data = ComponenteFormacion::with(['campo_disciplinar']) ->get(); return $data; } I only get the last element of "field_disciplinary"...
asked by 15.03.2017 / 04:07
1
answer

Consult select with eloquent in Laravel

I'm starting with Laravel and I have two simple entities that are users and notas , which are related in the following way: Users public function notes() { return $this->hasMany('App\Note'); } Notes public functio...
asked by 16.01.2018 / 14:51
1
answer

Problem with a query to the database from Eloquent / PHP

I'm doing a SELECT query to my database, but I do not get what I want I've been reading the framework documentation, but I have not found the answer. This is what I have: public function getUpdate(){ 1-$id = $_GET['id']; 2-var_dump($i...
asked by 06.07.2018 / 05:42
2
answers

How to ask the user a confirmation to delete object?

I have an inconvenience that when the user wants to delete a post it is deleted without further ado, but I want to ask the user some confirmation if he wants to delete it, I am working with php, eloquent, twige illuminate, for now I have this pa...
asked by 07.07.2018 / 16:41
2
answers

How to transcribe sql query in Laravel ??

My query is the following as I can transcribe the following SQL for laravel: SELECT movimientos.descripcion as Detalle, desde.descripcion AS desde, destino.descripcion AS destino FROM movimientos JOIN almacens desde on desde.id_almacen=...
asked by 14.05.2018 / 17:15
1
answer

How to define an alias to columns with the same name in Laravel?

I have a question. how do I define the alias for columns with the same name ????. In particular I wish to consult my Database with records related to laravel in the following way $proveedor =DB::table('proveedors') ->join('pais'...
asked by 08.05.2018 / 20:57
2
answers

belongsTo error in AppServiceProvider

I have an error in the belongsTo relationship in the welcome view, the error is the following: "Undefined property: stdClass::$work (View: ...\views\welcome.blade.php)" I recover the data from the query made in AppServiceProvider since it i...
asked by 26.11.2017 / 21:34
1
answer

How to use with laravel 5.6 in two models and get your data

Hello, I have a table called ReserveTable and another table called Fields I want to get the data of the model of the court: public function reserva(){ return $this->belongsTo('App\ReservaTable','idcanchas', 'idcanchas'); } in my Cont...
asked by 05.12.2018 / 19:22
1
answer

Does anyone know how I can do this type of Eloquent query?

I need to have a query builder. The only way that has occurred to me is to make a string, and in the string form the eloquent query. I only have a problem executing the query. $variable = "where('a','asd')->get()"; return Modelo::$variable;...
asked by 21.11.2018 / 21:23