Example #1
0
 /**
  * Set the Tiket Number
  *
  * @param  string  $value
  * @return string
  */
 public function setTiketAttribute($value)
 {
     /**
      * Tiket automatico, segĂșn numero de id.
      */
     if (!$value) {
         if (!$this->attributes['id']) {
             $tiket = Parking::where('id', '>', '0')->orderBy('created_at', 'desc')->first();
             if ($tiket) {
                 $tiket_id = $tiket->id + 1;
             } else {
                 $tiket_id = 1;
             }
         } else {
             $tiket_id = $this->attributes['id'];
         }
         $this->attributes['tiket'] = str_pad($tiket_id, 6, "0", STR_PAD_LEFT);
     } else {
         $this->attributes['tiket'] = $value;
     }
 }