add 'returned' flag in items
This commit is contained in:
parent
6bdbd2039b
commit
b349690996
4 changed files with 61 additions and 16 deletions
|
@ -7,6 +7,7 @@ use App\File;
|
||||||
use App\Item;
|
use App\Item;
|
||||||
use App\Event;
|
use App\Event;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class ItemController extends Controller
|
class ItemController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -19,18 +20,18 @@ class ItemController extends Controller
|
||||||
public function showByEvent($event)
|
public function showByEvent($event)
|
||||||
{
|
{
|
||||||
$eid = Event::where('slug','=',$event)->first()->eid;
|
$eid = Event::where('slug','=',$event)->first()->eid;
|
||||||
return response()->json(Item::where('eid','=',$eid)
|
$q = Item::where('eid','=',$eid)->whereNull('returned_at')
|
||||||
->join('containers','items.cid','=','containers.cid')
|
->join('containers','items.cid','=','containers.cid')
|
||||||
->leftJoin('currentfiles','items.iid','=','currentfiles.iid')
|
->leftJoin('currentfiles','items.iid','=','currentfiles.iid')
|
||||||
->select('items.*','currentfiles.hash as file', 'containers.name as box')
|
->select('items.*','currentfiles.hash as file', 'containers.name as box');
|
||||||
->get());
|
return response()->json($q->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function searchByEvent($event, $query)
|
public function searchByEvent($event, $query)
|
||||||
{
|
{
|
||||||
$eid = Event::where('slug','=',$event)->first()->eid;
|
$eid = Event::where('slug','=',$event)->first()->eid;
|
||||||
$query_tokens = explode(" ",base64_decode ( $query , true));
|
$query_tokens = explode(" ",base64_decode ( $query , true));
|
||||||
$q = Item::where('eid','=',$eid)
|
$q = Item::where('eid','=',$eid)->whereNull('returned_at')
|
||||||
->join('containers','items.cid','=','containers.cid')
|
->join('containers','items.cid','=','containers.cid')
|
||||||
->leftJoin('currentfiles','items.iid','=','currentfiles.iid')
|
->leftJoin('currentfiles','items.iid','=','currentfiles.iid')
|
||||||
->select('items.*','currentfiles.hash as file', 'containers.name as box');
|
->select('items.*','currentfiles.hash as file', 'containers.name as box');
|
||||||
|
@ -74,6 +75,11 @@ class ItemController extends Controller
|
||||||
$item = Item::where('eid', $eid)->where('item_uid', $id)->first();
|
$item = Item::where('eid', $eid)->where('item_uid', $id)->first();
|
||||||
$item->update($request->except(['file', 'box', 'dataImage']));
|
$item->update($request->except(['file', 'box', 'dataImage']));
|
||||||
|
|
||||||
|
if($request->get('returned')===true){
|
||||||
|
$item->update(['returned_at' => DB::raw( 'current_timestamp' )]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->get('dataImage')) {
|
||||||
$pos = strpos($request->get('dataImage'), ",");
|
$pos = strpos($request->get('dataImage'), ",");
|
||||||
//$head = substr($request->get('dataImage'), 0, $pos);
|
//$head = substr($request->get('dataImage'), 0, $pos);
|
||||||
$image = base64_decode(substr($request->get('dataImage'), $pos + 1), true);
|
$image = base64_decode(substr($request->get('dataImage'), $pos + 1), true);
|
||||||
|
@ -84,6 +90,7 @@ class ItemController extends Controller
|
||||||
file_put_contents('staticimages/' . $hash, $image);
|
file_put_contents('staticimages/' . $hash, $image);
|
||||||
$file = File::create(array('hash' => $hash, 'iid' => $item['iid']));
|
$file = File::create(array('hash' => $hash, 'iid' => $item['iid']));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return response()->json($item, 200);
|
return response()->json($item, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ class Item extends Model
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'iid', 'item_uid', 'description', 'wann', 'wo', 'eid', 'cid'
|
'iid', 'item_uid', 'description', 'wann', 'wo', 'eid', 'cid', 'returned_at'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,6 +26,9 @@ class Item extends Model
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $hidden = ['created_at','updated_at', 'deleted_at', 'eid', 'iid'];
|
protected $hidden = ['created_at','updated_at', 'deleted_at', 'returned_at', 'eid', 'iid', 'wann', 'wo'];
|
||||||
|
|
||||||
|
public static function restored($callback)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddItemReturnedAtMember extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Schema::table('items', function (Blueprint $table) {
|
||||||
|
$table->timestamp('returned_at')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('items', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('returned_at');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,6 +12,8 @@ $thumb = getcwd() . $_GET["id"];
|
||||||
$img = str_replace("thumbnails", "staticimages", $thumb);
|
$img = str_replace("thumbnails", "staticimages", $thumb);
|
||||||
if (is_file($img)) {
|
if (is_file($img)) {
|
||||||
try {
|
try {
|
||||||
|
if(!file_exists("thumbnails"))
|
||||||
|
mkdir("thumbnails");
|
||||||
$imagick = new Imagick($img);
|
$imagick = new Imagick($img);
|
||||||
$imagick->setImageFormat('jpeg');
|
$imagick->setImageFormat('jpeg');
|
||||||
$imagick->setImageCompression(Imagick::COMPRESSION_JPEG);
|
$imagick->setImageCompression(Imagick::COMPRESSION_JPEG);
|
||||||
|
|
Loading…
Reference in a new issue