Last active
October 15, 2020 14:59
-
-
Save fatkulnurk/458abd1d31f1ebdc251296c562440915 to your computer and use it in GitHub Desktop.
mutator tidak berfungsi jika menggunakan method upsert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PrepaidProduct::upsert($collection, ['buyer_sku_code'], | |
[ | |
'product_name', | |
'category', | |
'brand', | |
'type', | |
'seller_name', | |
'price', | |
'buyer_product_status', | |
'seller_product_status', | |
'unlimited_stock', | |
'stock', | |
'multi', | |
'start_cut_off', | |
'end_cut_off', | |
'desc', | |
]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Models; | |
use Illuminate\Database\Eloquent\Factories\HasFactory; | |
use Illuminate\Database\Eloquent\Model; | |
use Illuminate\Database\Eloquent\SoftDeletes; | |
use Illuminate\Support\Str; | |
class PostpaidProduct extends Model | |
{ | |
use HasFactory; | |
use SoftDeletes; | |
protected $guarded = []; | |
public function setProductNameAttribute($value) | |
{ | |
$this->attributes['product_name'] = Str::lower($value); | |
} | |
public function setCategoryAttribute($value) | |
{ | |
$this->attributes['category'] = Str::lower($value); | |
} | |
public function setBrandAttribute($value) | |
{ | |
$this->attributes['brand'] = Str::upper($value); | |
} | |
public function setSellerNameAttribute($value) | |
{ | |
$this->attributes['seller_name'] = Str::upper($value); | |
} | |
public function transactions() | |
{ | |
return $this->hasMany(TransactionPostpaid::class); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment