-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
65 additions
and
41 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/src/.DS_Store | ||
./vendor/* | ||
/.idea | ||
/.idea | ||
/vendor/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,29 +14,32 @@ | |
use Illuminate\Routing\Controller; | ||
|
||
/** | ||
* @author: Dyan Galih<[email protected]> https://dyangalih.com | ||
* @author: Dyan Galih<[email protected]> | ||
* Date: 18/04/20 | ||
* Time: 18.55 | ||
* Class BaseController | ||
* @package WebAppId\DDD\Controllers | ||
*/ | ||
class BaseController extends Controller | ||
{ | ||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests; | ||
|
||
/** | ||
* @var Container | ||
*/ | ||
private $container; | ||
protected $container; | ||
|
||
public function __construct(Container $container) | ||
{ | ||
$this->container = $container; | ||
} | ||
|
||
/** | ||
* @return Container | ||
* @deprecated | ||
*/ | ||
protected function getContainer() | ||
{ | ||
return $this->container; | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,11 @@ | |
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
/** | ||
* @author: Dyan Galih<[email protected]> https://dyangalih.com | ||
* @author: Dyan Galih<[email protected]> | ||
* Date: 18/04/20 | ||
* Time: 18.55 | ||
* Class AbstractFormRequest | ||
* @package WebAppId\DDD\Requests | ||
*/ | ||
abstract class AbstractFormRequest extends FormRequest implements FormRequestContract | ||
{ | ||
|
@@ -22,25 +25,25 @@ public function authorize(): bool | |
{ | ||
return true; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
abstract function rules(): array; | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function messages(): array | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function attributes(): array | ||
{ | ||
return []; | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,16 +8,19 @@ | |
namespace WebAppId\DDD\Requests; | ||
|
||
/** | ||
* @author: Dyan Galih<[email protected]> https://dyangalih.com | ||
* @author: Dyan Galih<[email protected]> | ||
* Date: 18/04/20 | ||
* Time: 18.55 | ||
* Interface FormRequestContract | ||
* @package WebAppId\DDD\Requests | ||
*/ | ||
interface FormRequestContract | ||
{ | ||
public function authorize(): bool; | ||
|
||
public function rules(): array; | ||
|
||
public function messages(): array; | ||
|
||
public function attributes(): array; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,57 +8,65 @@ | |
namespace WebAppId\DDD\Responses; | ||
|
||
/** | ||
* @author: Dyan Galih<[email protected]> https://dyangalih.com | ||
* @author: Dyan Galih<[email protected]> | ||
* Date: 18/04/20 | ||
* Time: 18.55 | ||
* Class AbstractResponse | ||
* @package WebAppId\DDD\Responses | ||
*/ | ||
abstract class AbstractResponse | ||
{ | ||
/** | ||
* @var bool | ||
*/ | ||
private $status; | ||
protected $status; | ||
/** | ||
* @var string | ||
*/ | ||
private $message; | ||
protected $message; | ||
|
||
/** | ||
* @return bool | ||
* @deprecated | ||
*/ | ||
public function isStatus(): bool | ||
{ | ||
return $this->status; | ||
} | ||
|
||
/** | ||
* @return bool | ||
* @deprecated | ||
*/ | ||
public function getStatus(): bool | ||
{ | ||
return $this->status; | ||
} | ||
|
||
/** | ||
* @param bool $status | ||
* @deprecated | ||
*/ | ||
public function setStatus(bool $status): void | ||
{ | ||
$this->status = $status; | ||
} | ||
|
||
/** | ||
* @return string | ||
* @deprecated | ||
*/ | ||
public function getMessage(): string | ||
{ | ||
return $this->message; | ||
} | ||
|
||
/** | ||
* @param string $message | ||
* @deprecated | ||
*/ | ||
public function setMessage(string $message): void | ||
{ | ||
$this->message = $message; | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,16 +11,19 @@ | |
use Illuminate\Container\Container; | ||
|
||
/** | ||
* @author: Dyan Galih<[email protected]> https://dyangalih.com | ||
* @author: Dyan Galih<[email protected]> | ||
* Date: 18/04/20 | ||
* Time: 18.55 | ||
* Class BaseService | ||
* @package WebAppId\DDD\Services | ||
*/ | ||
class BaseService | ||
{ | ||
/** | ||
* @var Container | ||
*/ | ||
private $container; | ||
protected $container; | ||
|
||
/** | ||
* BaseService constructor. | ||
* @param Container $container | ||
|
@@ -29,12 +32,12 @@ public function __construct(Container $container) | |
{ | ||
$this->container = $container; | ||
} | ||
|
||
/** | ||
* @return Container | ||
*/ | ||
protected function getContainer(): Container | ||
{ | ||
return $this->container; | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,12 +12,15 @@ | |
use Illuminate\Database\Eloquent\Model; | ||
|
||
/** | ||
* @author: Dyan Galih<[email protected]> https://dyangalih.com | ||
* @author: Dyan Galih<[email protected]> | ||
* Date: 18/04/20 | ||
* Time: 18.56 | ||
* Class PopoTools | ||
* @package WebAppId\DDD\Tools | ||
*/ | ||
class PopoTools | ||
{ | ||
|
||
/** | ||
* @param mixed $object | ||
* @return string|false | ||
|
@@ -26,7 +29,7 @@ public function serializeJson($object) | |
{ | ||
return json_encode($this->serialize($object)); | ||
} | ||
|
||
private function fixKey($key): string | ||
{ | ||
if (stripos($key, "\0") === 0) { | ||
|
@@ -36,17 +39,17 @@ private function fixKey($key): string | |
} | ||
return $newKey; | ||
} | ||
|
||
/** | ||
* @param $object | ||
* @return array | ||
*/ | ||
public function serialize($object) | ||
{ | ||
$objectAsArray = (array)$object; | ||
|
||
foreach ($objectAsArray as $key => $value) { | ||
|
||
$newKey = $this->fixKey($key); | ||
if ($newKey != $key) { | ||
$this->replaceKey($objectAsArray, $key, $newKey); | ||
|
@@ -71,10 +74,10 @@ public function serialize($object) | |
} | ||
} | ||
} | ||
|
||
return $objectAsArray; | ||
} | ||
|
||
/** | ||
* @param $array | ||
* @param $curkey | ||
|
@@ -88,10 +91,10 @@ function replaceKey(&$array, $curkey, $newkey) | |
unset($array[$curkey]); | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* @param string $oldKey | ||
* @return string | ||
|