public static function strMaxLength(BaseModel $model, $propName, $maxLength, $scenario = []) { if (isset($model->{$propName}) && (empty($scenario) || in_array($model->scenario, $scenario))) { if (!is_string($model->{$propName})) { $model->addErrorMsg($propName, 'Should be string!'); return; } if (mb_strlen('$model->{$propName}') < $maxLength) { return; } $model->addErrorMsg($propName, 'Max length should be not greater then ' . $maxLength); } }
static function boot() { parent::boot(); Static::observe(new HeadlineObserver()); Static::observe(new HasManyImagesObserver()); Static::observe(new BelongsToTravelAgentObserver()); }
static function boot() { parent::boot(); Static::observe(new DestinationObserver()); Static::observe(new HasNameObserver()); Static::observe(new TreeObserver()); }
public static function boot() { parent::boot(); Region::deleted(function ($region) { $region->quotations()->delete(); }); }
public static function boot() { parent::boot(); static::saved(function ($model) { $targetKerja = TargetKerja::find($model->attributes['target_kerja_id']); // hitung nilai $nilais = []; if ($targetKerja->kuantitas) { // 1. Kuantitas = Realisasi Output / Target Output * 100 $nilais[] = $kuantitas = $model->attributes['kuantitas'] / $targetKerja->kuantitas * 100; } if ($targetKerja->kualitas) { // 2. Kualitas = Realisasi Output / Target Output * 100 $nilais[] = $kualitas = $model->attributes['kualitas'] / $targetKerja->kualitas * 100; } if ($targetKerja->waktu) { // 3. Waktu = (1.76 * Target Waktu - Realisasi Waktu) / Target Waktu * 100 $nilais[] = $waktu = (1.76 * $targetKerja->waktu - $model->attributes['waktu']) / $targetKerja->waktu * 100; } if ($targetKerja->biaya) { // 4. Biaya = (1.76 * Target Biaya - Realisasi Biaya) / Target Biaya * 100 $nilais[] = $biaya = (1.76 * $targetKerja->biaya - $model->attributes['biaya']) / $targetKerja->biaya * 100; } $total_nilai = collect($nilais)->sum(); $score = Score::firstOrNew(['target_kerja_id' => $targetKerja->id]); $score->fill(compact('kuantitas', 'kualitas', 'waktu', 'biaya', 'total_nilai')); $targetKerja->score()->save($score); $nilai = collect($nilais)->average(); $targetKerja->update(compact('nilai')); }); }
static function boot() { parent::boot(); Static::observe(new PackageObserver()); Static::observe(new HasNameObserver()); Static::observe(new HasSlugObserver()); }
static function boot() { parent::boot(); Static::observe(new TourObserver()); Static::observe(new HasNameObserver()); Static::observe(new HasSlugObserver()); Static::observe(new HasPublishedAtObserver()); }
public function __construct(array $attributes = []) { parent::__construct($attributes); $this->manejaConcurrencia = false; }
public function getFillable() { $fillable = parent::getFillable(); return array_flip(array_except(array_flip($fillable), ['pengguna_id'])); }
static function boot() { parent::boot(); Static::observe(new TourScheduleObserver()); }
static function boot() { parent::boot(); Static::observe(new SettingObserver()); }
static function boot() { parent::boot(); Static::observe(new AddressObserver()); }
static function boot() { parent::boot(); Static::observe(new TourOptionObserver()); Static::observe(new HasNameObserver()); }
public function __construct() { // Call parent construct to load the config parent::__construct(); }
public function save(array $options = array()) { // $this->grab_bs(); parent::save($options); self::addAllToIndex(); return true; }
/** * @param string|null $scenario */ public function __constructor($scenario = null) { parent::__construct($scenario); }
static function boot() { parent::boot(); Static::observe(new PhoneObserver()); }
static function boot() { parent::boot(); Static::observe(new TravelAgentObserver()); Static::observe(new HasNameObserver()); }