Created
July 2, 2020 14:39
-
-
Save sinyo1015/9bbb03a3a742fbed6148eafeb34e2127 to your computer and use it in GitHub Desktop.
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 | |
class AutoNumber{ | |
protected $prefix; | |
protected $lastIndex; | |
protected $indexNext; | |
public function __construct($data){ | |
$this->prefix = $data[0]; | |
$this->lastIndex = $data[1]; | |
$this->indexNext = $data[2]; | |
} | |
public function make($existing){ | |
$number = (int) substr($existing, $this->indexNext, $this->lastIndex); | |
$newNumber = $number + 1; | |
$realLength = ($this->lastIndex - $this->indexNext); | |
$formatter = "%0" . $realLength . "s"; | |
return $this->prefix . sprintf($formatter, $newNumber); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A PHP Error was encountered
Severity: Notice
Message: Undefined index: harga_lapangan
Filename: api/Booking.php
Line Number: 27
Backtrace:
File: C:\xampp\htdocs\temp\application\controllers\api\Booking.php
Line: 27
Function: _error_handler
File: C:\xampp\htdocs\temp\application\libraries\REST_Controller.php
Line: 742
Function: call_user_func_array
File: C:\xampp\htdocs\temp\index.php
Line: 315
Function: require_once
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Booking::$AutoNumber
Filename: api/Booking.php
Line Number: 35
Backtrace:
File: C:\xampp\htdocs\temp\application\controllers\api\Booking.php
Line: 35
Function: _error_handler
File: C:\xampp\htdocs\temp\application\libraries\REST_Controller.php
Line: 742
Function: call_user_func_array
File: C:\xampp\htdocs\temp\index.php
Line: 315
Function: require_once
An uncaught Exception was encountered
Type: Error
Message: Call to a member function make() on null
Filename: C:\xampp\htdocs\temp\application\controllers\api\Booking.php
Line Number: 35
Backtrace:
File: C:\xampp\htdocs\temp\application\libraries\REST_Controller.php
Line: 742
Function: call_user_func_array
File: C:\xampp\htdocs\temp\index.php
Line: 315
Function: require_once