very hacky implementation of item create endpoint
This commit is contained in:
parent
edc7078c51
commit
5b8686599f
2 changed files with 26 additions and 12 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Container;
|
||||
use App\File;
|
||||
use App\Item;
|
||||
use App\Event;
|
||||
use Illuminate\Http\Request;
|
||||
|
@ -44,9 +46,16 @@ class ItemController extends Controller
|
|||
public function create($event, Request $request)
|
||||
{
|
||||
$eid = Event::where('slug','=',$event)->first()->eid;
|
||||
$data = $request->all();
|
||||
$data['eid'] = "".$eid;
|
||||
$item = Item::create($data);
|
||||
$newitem = $request->except(['dataImage']);
|
||||
$newitem['eid'] = "".$eid;
|
||||
$newitem['item_uid'] = "".rand(10, 100);
|
||||
$newitem['wo'] = "";
|
||||
$item = Item::create($newitem);
|
||||
$dataImage = $request->get('dataImage');
|
||||
$hash = md5(time());
|
||||
mkdir('staticimages');
|
||||
file_put_contents('staticimages/'.$hash, base64_decode($dataImage));
|
||||
$file = File::create(array('hash' => $hash, 'iid'=> $item['iid']));
|
||||
return response()->json($item, 201);
|
||||
}
|
||||
|
||||
|
@ -62,6 +71,6 @@ class ItemController extends Controller
|
|||
{
|
||||
$eid = Event::where('slug','=',$event)->first()->eid;
|
||||
Item::where('eid', $eid)->where('item_uid', $id)->first()->delete();
|
||||
return response()->json(array("satus"=>'Deleted Successfully'), 200);
|
||||
return response()->json(array("status"=>'Deleted Successfully'), 200);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,14 +11,19 @@ $quality = 90;
|
|||
$thumb = getcwd() . $_GET["id"];
|
||||
$img = str_replace("thumbnails", "staticimages", $thumb);
|
||||
if (is_file($img)) {
|
||||
$imagick = new Imagick($img);
|
||||
$imagick->setImageFormat('jpeg');
|
||||
$imagick->setImageCompression(Imagick::COMPRESSION_JPEG);
|
||||
$imagick->setImageCompressionQuality($quality);
|
||||
$imagick->cropThumbnailImage($width, $height);
|
||||
$imagick->setImagePage(0, 0, 0, 0);
|
||||
if (file_put_contents($thumb, $imagick) === false) {
|
||||
log_error("Could not put contents.");
|
||||
try {
|
||||
$imagick = new Imagick($img);
|
||||
$imagick->setImageFormat('jpeg');
|
||||
$imagick->setImageCompression(Imagick::COMPRESSION_JPEG);
|
||||
$imagick->setImageCompressionQuality($quality);
|
||||
$imagick->cropThumbnailImage($width, $height);
|
||||
$imagick->setImagePage(0, 0, 0, 0);
|
||||
if (file_put_contents($thumb, $imagick) === false) {
|
||||
log_error("Could not put contents.");
|
||||
}
|
||||
}catch(Exception $exception){
|
||||
log_error($exception);
|
||||
$imagick = file_get_contents($img);
|
||||
}
|
||||
|
||||
header("Content-type: image/jpeg");
|
||||
|
|
Loading…
Reference in a new issue