(Update) Gallery System

- ability for user to delete there own album assuming its within 24
hours of creation date.
This commit is contained in:
HDVinnie
2018-06-10 11:39:01 -04:00
parent d58006e31b
commit 0d4b56b47a
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -16,6 +16,7 @@ use Illuminate\Http\Request;
use App\Services\Clients\OmdbClient;
use App\Album;
use Image;
use Carbon\Carbon;
use \Toastr;
class AlbumController extends Controller
@@ -127,8 +128,9 @@ class AlbumController extends Controller
*/
public function destroy($id)
{
if (auth()->user()->group->is_modo) {
$album = Album::findOrFail($id);
$album = Album::findOrFail($id);
if (auth()->user()->group->is_modo || (auth()->user()->id == $album->user_id && Carbon::now()->lt($album->created_at->addDay()))) {
$album->delete();
return redirect()->route('home')
+1 -1
View File
@@ -37,7 +37,7 @@
<a href="{{ route('add_image', ['id' => $album->id]) }}">
<button type="button" class="btn btn-success btn-md">Add New Image to Album</button>
</a>
@if(auth()->user()->group->is_modo)
@if(auth()->user()->group->is_modo || auth()->user()->id == $album->user_id && Carbon\Carbon::now()->lt($album->created_at->addDay()))
<a href="{{ route('delete_album', ['id' => $album->id]) }}"
onclick="return confirm('Are you sure?')">
<button type="button" class="btn btn-danger btn-md">Delete Album</button>