Questions tagged as 'laravel-eloquent'

1
answer

distant relationship with laravel

I have this table structure and would like to know if the person who posted the thread or the reply member or moderator in> but I could not structure a relationship that works, can anyone help me? forum id - integer name - s...
asked by 16.08.2014 / 23:02
3
answers

Return only the newest record of each author

I have a table with the following fields: id, texto, autor_id, data I need the records to be grouped by autor_id (because it has multiple texts with the same author) and I get the newest ones in ascending order only. I'm using Lavare...
asked by 16.03.2014 / 01:57
3
answers

Update record with Laravel 5.2?

I have the following function: public function alterar($id) { $produto = Produto::find($id); $params = $request->all(); $produto->fill($params)->save(); return redirect()->action('ProdutoController@index'); } how...
asked by 03.08.2016 / 23:42
3
answers

Difference between create and fill - laravel method

I was developing a web service with laravel, and I realized that I can save the data in my bank in two ways: Product::create($request->all()); or else: $product = new Product(); $product->fill($request->all()); $product->save(...
asked by 23.04.2018 / 14:08
2
answers

Date being recorded wrong in bank m-d-Y instead of Y-m-d

I set the date format for viewing to "d-m-Y", while the recording format is the "Y-m-d" bank. However at the time of recording in the bank, something happens and the data is going in the format "mdY", and with that the data will be truncated,...
asked by 22.12.2013 / 23:37
1
answer

Many relationship to many laravel

Well, I've tried to read the documentation and develop this relationship, but I can not really tell you what the user's name is. The database model looks like this: % of% involved App\User App\TipoUser App\UserTipo And in my model i...
asked by 04.05.2017 / 01:45
2
answers

Doubt when performing SQL with Eloquent of Laravel

I have a bug that I do not know the reason for it. I have in my controller the following Eloquent : $balances = BankUser::select(DB::raw('SUM(balance) AS total, created_at, DATE(created_at) AS total_at'))...
asked by 12.12.2018 / 16:46
1
answer

How to filter time in a datime field in eloquent?

How can I compare if a time is equal to a time stored in a datetime column using Eloquent?     
asked by 25.10.2018 / 19:24
1
answer

General error: 1215 Can not add foreign key constraint

I'm trying to add a foreign key to this table with the following code block public function up() { Schema::create('registros', function (Blueprint $table) { $table->increments('id'); $table->integer( 'cliente' )-&g...
asked by 23.11.2017 / 20:53
1
answer

How to use laravel paginate with a manual query?

I have a manual query in my model, and I want to return to view of blade the result of this query with pagination. Is there any way?    Model class Ticket extends Model { protected $fillable = [ 'id',...
asked by 06.09.2016 / 21:09