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