2016-09-02 21:27:50 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
|
|
|
|
use App\Photo;
|
|
|
|
use App\Upload;
|
|
|
|
use App\UploadPhoto;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use Illuminate\Http\UploadedFile;
|
2016-09-02 22:00:42 +01:00
|
|
|
use Symfony\Component\HttpFoundation\File\File;
|
2016-09-02 21:27:50 +01:00
|
|
|
|
|
|
|
class PhotoController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Display a listing of the resource.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for creating a new resource.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function create()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store a newly created resource in storage.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function store(Request $request)
|
|
|
|
{
|
|
|
|
$this->authorize('admin-access');
|
|
|
|
|
|
|
|
/** @var UploadedFile $photoFile */
|
|
|
|
$photoFile = UploadedFile::createFromBase($request->files->get('photo'));
|
|
|
|
|
|
|
|
// Load the linked album
|
|
|
|
$album = AlbumController::loadAlbum($request->get('album_id'));
|
|
|
|
|
2016-09-02 22:00:42 +01:00
|
|
|
/** @var File $savedFile */
|
|
|
|
$savedFile = $album->getAlbumSource()->saveUploadedPhoto($album, $photoFile);
|
2016-09-02 21:27:50 +01:00
|
|
|
|
|
|
|
$photo = new Photo();
|
|
|
|
$photo->album_id = $album->id;
|
|
|
|
$photo->name = $photoFile->getClientOriginalName();
|
2016-09-02 22:00:42 +01:00
|
|
|
$photo->file_name = $savedFile->getFilename();
|
|
|
|
$photo->mime_type = $savedFile->getMimeType();
|
|
|
|
$photo->file_size = $savedFile->getSize();
|
2016-09-02 21:27:50 +01:00
|
|
|
$photo->save();
|
|
|
|
|
|
|
|
$upload = new Upload();
|
|
|
|
$upload->is_completed = false;
|
|
|
|
$upload->is_processing = false;
|
|
|
|
$upload->number_photos = 1;
|
|
|
|
$upload->save();
|
|
|
|
|
|
|
|
$uploadPhoto = new UploadPhoto();
|
|
|
|
$uploadPhoto->upload_id = $upload->id;
|
|
|
|
$uploadPhoto->photo_id = $photo->id;
|
|
|
|
$uploadPhoto->save();
|
|
|
|
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the specified resource.
|
|
|
|
*
|
|
|
|
* @param int $id
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function show($id)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for editing the specified resource.
|
|
|
|
*
|
|
|
|
* @param int $id
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function edit($id)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the specified resource in storage.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param int $id
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function update(Request $request, $id)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the specified resource from storage.
|
|
|
|
*
|
|
|
|
* @param int $id
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function destroy($id)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|