Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
 static function boot()
 {
     parent::boot();
     Static::observe(new HeadlineObserver());
     Static::observe(new HasManyImagesObserver());
     Static::observe(new BelongsToTravelAgentObserver());
 }
Ejemplo n.º 3
0
 static function boot()
 {
     parent::boot();
     Static::observe(new DestinationObserver());
     Static::observe(new HasNameObserver());
     Static::observe(new TreeObserver());
 }
Ejemplo n.º 4
0
 public static function boot()
 {
     parent::boot();
     Region::deleted(function ($region) {
         $region->quotations()->delete();
     });
 }
Ejemplo n.º 5
0
 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'));
     });
 }
Ejemplo n.º 6
0
 static function boot()
 {
     parent::boot();
     Static::observe(new PackageObserver());
     Static::observe(new HasNameObserver());
     Static::observe(new HasSlugObserver());
 }
Ejemplo n.º 7
0
 static function boot()
 {
     parent::boot();
     Static::observe(new TourObserver());
     Static::observe(new HasNameObserver());
     Static::observe(new HasSlugObserver());
     Static::observe(new HasPublishedAtObserver());
 }
Ejemplo n.º 8
0
 public function __construct(array $attributes = [])
 {
     parent::__construct($attributes);
     $this->manejaConcurrencia = false;
 }
Ejemplo n.º 9
0
 public function getFillable()
 {
     $fillable = parent::getFillable();
     return array_flip(array_except(array_flip($fillable), ['pengguna_id']));
 }
Ejemplo n.º 10
0
 static function boot()
 {
     parent::boot();
     Static::observe(new TourScheduleObserver());
 }
Ejemplo n.º 11
0
 static function boot()
 {
     parent::boot();
     Static::observe(new SettingObserver());
 }
Ejemplo n.º 12
0
 static function boot()
 {
     parent::boot();
     Static::observe(new AddressObserver());
 }
Ejemplo n.º 13
0
 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();
 }
Ejemplo n.º 15
0
 public function save(array $options = array())
 {
     // $this->grab_bs();
     parent::save($options);
     self::addAllToIndex();
     return true;
 }
Ejemplo n.º 16
0
 /**
  * @param string|null $scenario
  */
 public function __constructor($scenario = null)
 {
     parent::__construct($scenario);
 }
Ejemplo n.º 17
0
 static function boot()
 {
     parent::boot();
     Static::observe(new PhoneObserver());
 }
Ejemplo n.º 18
0
 static function boot()
 {
     parent::boot();
     Static::observe(new TravelAgentObserver());
     Static::observe(new HasNameObserver());
 }