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;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Container;
|
||||||
|
use App\File;
|
||||||
use App\Item;
|
use App\Item;
|
||||||
use App\Event;
|
use App\Event;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
@ -44,9 +46,16 @@ class ItemController extends Controller
|
||||||
public function create($event, Request $request)
|
public function create($event, Request $request)
|
||||||
{
|
{
|
||||||
$eid = Event::where('slug','=',$event)->first()->eid;
|
$eid = Event::where('slug','=',$event)->first()->eid;
|
||||||
$data = $request->all();
|
$newitem = $request->except(['dataImage']);
|
||||||
$data['eid'] = "".$eid;
|
$newitem['eid'] = "".$eid;
|
||||||
$item = Item::create($data);
|
$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);
|
return response()->json($item, 201);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +71,6 @@ class ItemController extends Controller
|
||||||
{
|
{
|
||||||
$eid = Event::where('slug','=',$event)->first()->eid;
|
$eid = Event::where('slug','=',$event)->first()->eid;
|
||||||
Item::where('eid', $eid)->where('item_uid', $id)->first()->delete();
|
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"];
|
$thumb = getcwd() . $_GET["id"];
|
||||||
$img = str_replace("thumbnails", "staticimages", $thumb);
|
$img = str_replace("thumbnails", "staticimages", $thumb);
|
||||||
if (is_file($img)) {
|
if (is_file($img)) {
|
||||||
$imagick = new Imagick($img);
|
try {
|
||||||
$imagick->setImageFormat('jpeg');
|
$imagick = new Imagick($img);
|
||||||
$imagick->setImageCompression(Imagick::COMPRESSION_JPEG);
|
$imagick->setImageFormat('jpeg');
|
||||||
$imagick->setImageCompressionQuality($quality);
|
$imagick->setImageCompression(Imagick::COMPRESSION_JPEG);
|
||||||
$imagick->cropThumbnailImage($width, $height);
|
$imagick->setImageCompressionQuality($quality);
|
||||||
$imagick->setImagePage(0, 0, 0, 0);
|
$imagick->cropThumbnailImage($width, $height);
|
||||||
if (file_put_contents($thumb, $imagick) === false) {
|
$imagick->setImagePage(0, 0, 0, 0);
|
||||||
log_error("Could not put contents.");
|
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");
|
header("Content-type: image/jpeg");
|
||||||
|
|
Loading…
Reference in a new issue