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