lundi 4 avril 2016

Laravel 5 save and update not working.

When I update a product, the data not are updated.

Follow code

My Controller

public function viewProduct( $name, $id )
{

    $product = $this->queryProducts()
                    ->where('produtos.id' , $id )
                    ->first();

    $product->count_view += 1;
    $product->save();
 }      

My Model

<?php
namespace App;    
use Illuminate\Database\Eloquent\Model;

class Products extends Model
{ 

protected $guarded = ['id'];
protected $table = 'produtos';
const CREATED_AT = 'created';
const UPDATED_AT = 'modified';
protected $fillable = ['count_view', 'nome'];

If i use

dd( $product->save() )

my return is true and i tried use the method save() from other way

$product->save( ['count_view' => 77 ] )

and/or

$product->update( ['count_view' => 77 ] )

But no way works



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire