Mutators:
https://laravel.com/docs/5.7/eloquent-mutators#defining-a-mutator
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
/**
* Get the user's first name.
*
* @param string $value
* @return string
*/
public function getFirstNameAttribute($value)
{
return ucfirst($value);
}
}
https://stackoverflow.com/questions/38430538/mutator-is-not-working-with-bulk-insertation
When you call Order::insert($orderArray);
, it doesn't touch Eloquent in fact. It just proxies the call to Query\Builder@insert() method.
So I think the mutator can't be used in that way.
No comments:
Post a Comment