Skip to content

Instantly share code, notes, and snippets.

@sinyo1015
Created July 2, 2020 14:39
Show Gist options
  • Save sinyo1015/9bbb03a3a742fbed6148eafeb34e2127 to your computer and use it in GitHub Desktop.
Save sinyo1015/9bbb03a3a742fbed6148eafeb34e2127 to your computer and use it in GitHub Desktop.
<?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);
}
}
@ekaru04
Copy link

ekaru04 commented Jul 2, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment