관리-도구
편집 파일: PirsingController.php
<?php namespace App\Http\Controllers; use App\PiercingCatalog; use Illuminate\Http\Request; class PirsingController extends Controller { public function getAll() { $objs = PiercingCatalog::with('prices')->get(); return $this->respon($objs); } public function getId($id = null) { $obj = PiercingCatalog::with('prices')->where('id',$id)->first(); return $this->respon($obj); } private function respon($obj) { if (!$obj) { $obj = new PiercingCatalog; } return response()->json([ 'data' => $obj->toArray() ]); } }