samedi 30 juin 2018

Form Intake & Mass assignment in Laravel

I'm developing a Laravel Web Application that involves storing lots of data in the database so far I've been using the regular Laravel Store as follows partially because I prefer this way & partially because I may need to use the Model Events in the future(Model Events don't fire in case of Mass Assignment):

$product = new Product;
$product->name = "EXT";
// MANY MORE FIELDS
$product->save();

But I've read somewhere that It's not a good practice to do it this way instead use the Mass assignment as that is faster & more efficient.

Is that correct? Should I keep using the method I'm using or should I switch to Mass Assignment/Update?

PS: I'm aware that the security risks from Mass Assignment can be averted by $gaurded & $fillable.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire