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