bookinventory/app/Http/Controllers/LookupController.php
Tyler a1ac81a73a
All checks were successful
continuous-integration/drone/push Build is passing
Add attachments, more pages
2020-12-26 19:34:07 -05:00

32 lines
705 B
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Book;
use App\Services\BookInformation\BookLookupService;
use Cache;
class LookupController {
public function lookup(BookLookupService $service, $isbn) {
$result = $service->lookup($isbn);
$arr = [
'success' => false
];
if ($result) {
$arr = array_merge($arr, [
'success' => true,
'data' => $result
]);
}
$book = Book::where('barcode', $isbn)->first();
if ($book) {
$arr['warning'] = 'Item already exists.<br />Location: ' . $book->location->name;
}
return response()->json($arr);
}
}