diff --git a/app/Album.php b/app/Album.php index 69b20ae..62ccca9 100644 --- a/app/Album.php +++ b/app/Album.php @@ -8,6 +8,7 @@ use App\Helpers\MiscHelper; use Illuminate\Database\Eloquent\Model; use Illuminate\Http\Request; use Illuminate\Notifications\Notifiable; +use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Route; class Album extends Model @@ -56,6 +57,19 @@ class Album extends Model return $this->belongsToMany(Permission::class, 'album_anonymous_permissions'); } + public function cameras() + { + return DB::table('photos') + ->where('album_id', $this->id) + ->groupBy('camera_make', 'camera_model', 'camera_software') + ->select('camera_make', 'camera_model', 'camera_software', DB::raw('count(*) as photo_count')) + ->orderBy('photo_count', 'desc') + ->orderBy('camera_make') + ->orderBy('camera_model') + ->orderBy('camera_software') + ->get(); + } + public function children() { return $this->hasMany(Album::class, 'parent_album_id')->withCount('photos'); diff --git a/app/Http/Controllers/Admin/AlbumController.php b/app/Http/Controllers/Admin/AlbumController.php index 49bf04f..82e36b8 100644 --- a/app/Http/Controllers/Admin/AlbumController.php +++ b/app/Http/Controllers/Admin/AlbumController.php @@ -350,6 +350,9 @@ class AlbumController extends Controller $request->session()->flash('_old_input', $album->toArray()); } + // Get the cameras used in this album + $cameras = $album->cameras(); + return Theme::render('admin.show_album', [ 'active_tab' => (strlen($activeTab) == 0) ? 'photos' : $activeTab, 'album' => $album, @@ -368,6 +371,7 @@ class AlbumController extends Controller 'refresh_thumbnails' => trans('admin.photo_actions.refresh_thumbnails'), 'delete' => trans('admin.photo_actions.delete') ], + 'cameras' => $cameras, 'error' => $request->session()->get('error'), 'existing_groups' => $existingGroups, 'existing_users' => $existingUsers, diff --git a/resources/lang/en/admin.php b/resources/lang/en/admin.php index 9663c22..a278c96 100644 --- a/resources/lang/en/admin.php +++ b/resources/lang/en/admin.php @@ -8,6 +8,15 @@ return [ 'album_appearance_intro' => 'The settings shown below control how this album appears to visitors in the gallery.', 'album_basic_info_heading' => 'Album information', 'album_basic_info_intro' => 'The album\'s name and description are displayed to visitors in the gallery. If you wish to change them, you can do so below.', + 'album_camera_make' => 'Manufacturer', + 'album_camera_model' => 'Model', + 'album_camera_photo_count' => 'Number of photos', + 'album_camera_software' => 'Software version', + 'album_cameras_heading' => 'Cameras used in this album', + 'album_cameras_tab' => 'Cameras', + 'album_cameras_text' => 'Blue Twilight analyses the Exif data in your photos to determine which cameras have been used. The cameras that were found are displayed below.', + 'album_no_cameras_found_p1' => 'No cameras were found', + 'album_no_cameras_found_p2' => 'Upload more photos to this album or ensure the cameras you use support Exif image tagging.', 'album_no_photos_p1' => 'No photos in this album', 'album_no_photos_p2' => 'Click the "Upload photos" button below to get started.', 'album_no_photos_p2_no_upload' => 'The album\'s owner has not uploaded any photos yet.', diff --git a/resources/views/themes/base/admin/show_album.blade.php b/resources/views/themes/base/admin/show_album.blade.php index 6b86bce..a1a49fb 100644 --- a/resources/views/themes/base/admin/show_album.blade.php +++ b/resources/views/themes/base/admin/show_album.blade.php @@ -27,6 +27,7 @@ @can('change-permissions', $album) @include(Theme::viewName('partials.tab'), ['tab_name' => 'permissions', 'tab_icon' => 'lock', 'tab_text' => trans('admin.album_security_tab')]) @endcan + @include(Theme::viewName('partials.tab'), ['tab_name' => 'cameras', 'tab_icon' => 'camera', 'tab_text' => trans('admin.album_cameras_tab')]) @include(Theme::viewName('partials.tab'), ['tab_name' => 'settings', 'tab_icon' => 'cog', 'tab_text' => trans('admin.album_settings_tab')]) @@ -41,6 +42,8 @@ {{-- Permissions --}} @include(Theme::viewName('partials.album_permissions_tab')) @endcan + {{-- Cameras --}} + @include(Theme::viewName('partials.album_cameras_tab')) {{-- Settings --}} @include(Theme::viewName('partials.album_settings_tab')) diff --git a/resources/views/themes/base/partials/album_cameras_tab.blade.php b/resources/views/themes/base/partials/album_cameras_tab.blade.php new file mode 100644 index 0000000..9d9f484 --- /dev/null +++ b/resources/views/themes/base/partials/album_cameras_tab.blade.php @@ -0,0 +1,31 @@ +
+ @if (count($cameras) == 0) +
+

@lang('admin.album_no_cameras_found_p1')

+

@lang('admin.album_no_cameras_found_p2')

+
+ @else +

@lang('admin.album_cameras_heading')

+

@lang('admin.album_cameras_text')

+ + + + + + + + + + + @foreach ($cameras as $camera) + + + + + + + @endforeach + +
@lang('admin.album_camera_make')@lang('admin.album_camera_model')@lang('admin.album_camera_software')@lang('admin.album_camera_photo_count')
{{ $camera->camera_make }}{{ $camera->camera_model }}{{ $camera->camera_software }}{{ $camera->photo_count }}
+ @endif +
\ No newline at end of file diff --git a/resources/views/themes/base/partials/single_photo_admin.blade.php b/resources/views/themes/base/partials/single_photo_admin.blade.php index a08585a..79356d3 100644 --- a/resources/views/themes/base/partials/single_photo_admin.blade.php +++ b/resources/views/themes/base/partials/single_photo_admin.blade.php @@ -1,5 +1,4 @@ @php ($field_prefix = sprintf('photo[%d]', $photo->id)) -
@@ -71,4 +70,5 @@
- \ No newline at end of file + +
\ No newline at end of file