You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
846 B

2 years ago
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Http\Resources\CollectionResource;
  4. use App\Models\Collection;
  5. use Illuminate\Http\Request;
  6. class CollectionController extends Controller
  7. {
  8. public function show(Collection $collection)
  9. {
  10. return new CollectionResource($collection);
  11. }
  12. public function store(Request $request)
  13. {
  14. $collection = Collection::create($request->all());
  15. return new CollectionResource($collection);
  16. }
  17. public function update(Request $request, Collection $collection)
  18. {
  19. $collection->update($request->all());
  20. return new CollectionResource($collection);
  21. }
  22. public function destroy(Collection $collection)
  23. {
  24. if ($collection->trashed()) {
  25. return $collection->restore();
  26. }
  27. return $collection->delete();
  28. }
  29. }