jeudi 25 avril 2019

Trailing data when get model result?

Controller is:

 public function index()
 {
    return InvoiceResource::collection(Invoice::get());
 }

Model is:

class Invoice extends Model
{
    protected $table = 'enterprise_invoces';

    protected $dates = [
        'created_at',
        'updated_at',
    ];

}

Resource is:

class InvoiceResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return parent::toArray($request);
    }
}

SQL dump is:

CREATE TABLE `enterprise_invoces` (
  `id` int(10) UNSIGNED NOT NULL,
  `id_enterprise` int(11) NOT NULL,
  `invoice_type` varchar(45) NOT NULL,
  `created_at` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
  `updated_at` timestamp(6) NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

I get exception messages as:

InvalidArgumentException {#250
  #message: "Trailing data"
  #code: 0
  #file: "C:\Projects\ruslan\vendor\nesbot\carbon\src\Carbon\Traits\Creator.php"
  #line: 537



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2Pwl7JJ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire