I have a simple form and a function to update my products. As this is not the only place where I will need to update products, I decided to move the function inside the model itself, so I can reuse it later:
class Producto extends Model
{
public function update($vales){
$this -> disponible = $values['disponible'];
$this -> tipo = $values['tipo'];
$this -> marca = $values['marca'];
$this -> visible = $values['visible'];
$this -> upc = $values['upc'];
$this -> save();
return;
}
}
Is it correct to update the model using $this? I tested it and it works and updates everything, except for the column called "visible". I tried to find what is wrong but everything seems to be just ok, and it looks like it just doesn't want to update that specific column.
I tried changing that line for testing purposes to:
$this -> visible = "some hardcoded value";
But it's still somehow not working... I tried updating the model from the controller using:
$product -> visible = $values['visible'];
And it works as expected, but the point of putting that function into the model is to make it reusable. Everything in the database looks ok, and this is driving me crazy. So the only thing that could be the problem as I can see is having to use $this to update the model, but I'm not sure if that is correct or not.