Update book table to cintain extra info
This commit is contained in:
@ -7,6 +7,7 @@ use App\Models\Book;
|
||||
use App\Models\Location;
|
||||
use App\Services\BookInformation\BookLookupService;
|
||||
use App\Services\BookInformation\GoogleBooks;
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
@ -74,13 +75,25 @@ class MainController extends Controller {
|
||||
$res = $service->lookup($item['barcode']);
|
||||
|
||||
if (!empty($res)) {
|
||||
if ($thumbnail = data_get('images.thumbnail', $res)) {
|
||||
if ($thumbnail = data_get($res, 'images.thumbnail')) {
|
||||
$file = $this->downloadFile($thumbnail);
|
||||
|
||||
$book->attach('thumbnail', $file);
|
||||
$attachment = $book->attach($file, [
|
||||
'key' => 'thumbnail'
|
||||
]);
|
||||
|
||||
$attachment->filename = 'thumbnail.jpg';
|
||||
$attachment->save();
|
||||
}
|
||||
|
||||
$book->description = $res->description;
|
||||
$book->published_date = Carbon::parse($res->published_date);
|
||||
$book->pages = $res->pages;
|
||||
$book->save();
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->route('locations.show', $location->id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user