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