Save a copy of all images, update navbar, add description
This commit is contained in:
parent
58e27a38ad
commit
1bd5aaaabd
|
@ -75,20 +75,31 @@ class MainController extends Controller {
|
||||||
$res = $service->lookup($item['barcode']);
|
$res = $service->lookup($item['barcode']);
|
||||||
|
|
||||||
if (!empty($res)) {
|
if (!empty($res)) {
|
||||||
if ($thumbnail = data_get($res, 'images.thumbnail')) {
|
if ($images = data_get($res, 'images')) {
|
||||||
$file = $this->downloadFile($thumbnail);
|
$images = array_filter($images, function($item) {
|
||||||
|
return !empty($item);
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach ($images as $key => $image) {
|
||||||
|
$file = $this->downloadFile($image);
|
||||||
|
|
||||||
$attachment = $book->attach($file, [
|
$attachment = $book->attach($file, [
|
||||||
'key' => 'thumbnail'
|
'key' => $key
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$attachment->filename = 'thumbnail.jpg';
|
$attachment->filename = $key . '.jpg';
|
||||||
$attachment->save();
|
$attachment->save();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$book->description = data_get($res, 'description');
|
||||||
|
|
||||||
|
if ($date = data_get($res, 'published_date')) {
|
||||||
|
$book->published_date = Carbon::parse($date);
|
||||||
|
}
|
||||||
|
|
||||||
|
$book->pages = data_get($res, 'pages', 0);
|
||||||
|
|
||||||
$book->description = $res->description;
|
|
||||||
$book->published_date = Carbon::parse($res->published_date);
|
|
||||||
$book->pages = $res->pages;
|
|
||||||
$book->save();
|
$book->save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,15 @@
|
||||||
</p>
|
</p>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<h5>Location:</h5>
|
<h5>Location</h5>
|
||||||
<p>
|
<p>
|
||||||
{{ $book->location->name }}
|
{{ $book->location->name }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@if (!empty($book->description))
|
||||||
|
<h5>Description</h5>
|
||||||
|
<p>
|
||||||
|
{{ $book->description }}
|
||||||
|
</p>
|
||||||
|
@endif
|
||||||
@endsection
|
@endsection
|
|
@ -7,13 +7,13 @@
|
||||||
|
|
||||||
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
|
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
|
||||||
<ul class="navbar-nav mr-auto">
|
<ul class="navbar-nav mr-auto">
|
||||||
<li class="nav-item active">
|
<li class="nav-item {{ Request::is('/') ? 'active' : '' }}">
|
||||||
<a class="nav-link" href="/">Home <span class="sr-only">(current)</span></a>
|
<a class="nav-link" href="/">Home <span class="sr-only">(current)</span></a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item {{ Request::segment(1) == 'locations' ? 'active' : '' }}">
|
||||||
<a class="nav-link" href="{{ route('locations.index') }}">Locations</a>
|
<a class="nav-link" href="{{ route('locations.index') }}">Locations</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item {{ Request::segment(1) == 'add' ? 'active' : '' }}">
|
||||||
<a class="nav-link" href="{{ route('add') }}">Add</a>
|
<a class="nav-link" href="{{ route('add') }}">Add</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Loading…
Reference in New Issue