/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // $attachment = Attachment::find($id); DB::beginTransaction(); // delete thumbnail if (\Input::get('name') == 'property') { $delete_thumb = \App\PropertyMeta::where('value', $attachment->file)->delete(); } if ($attachment->file) { if (\Input::get('name')) { \File::delete('uploads/images/' . \Input::get('name') . '/' . $attachment->file); } else { \File::delete('uploads/files/' . $attachment->file); } } $attachment->delete(); DB::commit(); return response()->json(array('status' => 200, 'monolog' => array('title' => 'delete success', 'message' => 'object has been deleted'), 'id' => $id)); }
public function thumb(Request $request) { // $thumb = PropertyMeta::where('property_id', $request->property_id)->where('type', 'thumbnail')->first(); if ($thumb) { $thumb->delete(); } $propertyMeta = new PropertyMeta(); $propertyMeta->property_id = $request->property_id; $propertyMeta->name = 'thumbnail'; $propertyMeta->value = $request->value; $propertyMeta->type = 'thumbnail'; $propertyMeta->save(); return response()->json(array('status' => 200, 'monolog' => array('title' => 'success', 'message' => 'object has been saved'))); }