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