29 lines
717 B
PHP
29 lines
717 B
PHP
<?php
|
|
|
|
namespace App\Traits;
|
|
|
|
use LaravelJsonApi\Core\Document\Error;
|
|
use LaravelJsonApi\Core\Document\ErrorList;
|
|
|
|
trait JsonApiCustomFunctionTraits
|
|
{
|
|
private function convertMessageBagToJSONAPIError($messageBag)
|
|
{
|
|
$errorList = ErrorList::fromArray([]);
|
|
foreach ($messageBag->toArray() as $key => $messageArray) {
|
|
|
|
$error = Error::fromArray([
|
|
/*
|
|
'status'=>201,
|
|
'id'=>99,
|
|
*/
|
|
'detail' => "'".$messageArray[0]."'",
|
|
'source' => ['pointer' => "'".$key."'"],
|
|
]);
|
|
$errorList->push($error);
|
|
}
|
|
|
|
return $errorList;
|
|
}
|
|
}
|