本文整理汇总了PHP中app\Image::destroy方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::destroy方法的具体用法?PHP Image::destroy怎么用?PHP Image::destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Image
的用法示例。
在下文中一共展示了Image::destroy方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteImage
public function deleteImage()
{
$user = Auth::User();
$userID = $user->id;
$image = Image::find($_POST['imageID']);
Storage::delete("{$userID}/{$image->imageName}");
Image::destroy($_POST['imageID']);
return "Image Deleted!";
}
示例2: updateImage
public function updateImage(Request $request)
{
$product = Product::find($request->prodid);
Image::destroy($request->imageid);
return response()->json('true');
}
示例3: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
Image::destroy($id);
return redirect('posts');
}
示例4: destroy
public function destroy($id)
{
Image::destroy($id);
return \Redirect::back()->withErrors('Image #' . $id . ' was deleted');
}
示例5: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($user, $id)
{
$album = Album::where(['id' => $id, 'user_id' => $user]);
$is_del = true;
if (count($album->get()->toArray())) {
$images = Album::find($id);
if (count($images) > 0) {
$images = $images->images()->get()->toArray();
foreach ($images as $image) {
$comment_img = Comment_image::where('image_id', $image['id']);
if (count($comment_img->get()->toArray())) {
if (false == $comment_img->delete()) {
$is_del = false;
}
}
if (false == unlink(public_path() . '/' . $image['fullsize_url']) || false == Image::destroy($image['id'])) {
$is_del = false;
break;
}
}
}
$album_id = $album->get()->first()->id;
$comment = Comment_album::where('album_id', $album_id);
if (count($comment->get()->toArray())) {
if (false == $comment->delete()) {
$is_del = false;
}
}
if ($album->delete() && true == $is_del) {
return redirect()->route('album.index', $user)->with(['message' => 'Album has been delete.']);
}
}
return redirect()->route('album.index', $user)->withErrors('Can not delete album.');
}
示例6: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request)
{
if (Auth::check()) {
//var_dump($request);
// get the user
$user = Auth::user();
$userid = $user->id;
$emailaddress = $user->email;
// get info from form
$tbd = $request->input('tbd');
$notes = $request->input('notes');
$websites = $request->input('websites');
try {
// update tbd and notes
DB::table('users')->where('id', '=', $userid)->update(['tbd' => $tbd, 'notes' => $notes]);
// remove all websites for this person
DB::table('websites')->where('userid', '=', $userid)->delete();
// add the new websites
foreach ($websites as $website) {
if (!empty($website)) {
DB::table('websites')->insert(['userid' => $userid, 'website' => $website]);
}
}
// clear websites
unset($websites);
// reload websites
$websites = DB::table('websites')->where('userid', '=', $userid)->orderBy('id', 'asc')->get();
// IMAGES //
if (Input::hasFile('image')) {
$file = array('image' => Input::file('image'));
$rules = array('image' => 'required|mimes:jpeg,jpg,gif');
$validator = Validator::make($file, $rules);
if ($validator->fails()) {
return redirect('home')->withErrors($validator);
} else {
if (Input::file('image')->isValid()) {
//save file to disk first
$extension = Input::file('image')->getClientOriginalExtension();
$size = Input::file('image')->getSize();
// getting image extension
$filecheck = false;
while ($filecheck == false) {
$fileName = rand(11111, 99999) . '.' . $extension;
// renameing image
if (!Storage::disk('local')->exists($emailaddress . "/" . $fileName)) {
$filecheck = true;
}
}
// $destinationPath = base_path() . '/public/images/' . $emailaddress; // upload path
// upload to database
if ($size < 19999999) {
$imagecontents = file_get_contents(Input::file('image'));
$mime = Input::file('image')->getClientMimeType();
DB::table('images')->insert(['email' => $emailaddress, 'name' => $fileName, 'image' => $imagecontents, 'mime' => $mime]);
// Move the file to the temp directory.
Storage::put($emailaddress . "/" . $fileName, $imagecontents);
//Input::file('image')->move($destinationPath, $fileName); // uploading file to given path
}
}
}
}
// delete images
//var_dump($imglist);
$imglist = array($request->input('images'));
//var_dump($imglist[0]);
if (isset($imglist[0])) {
foreach ($imglist[0] as $i => $ivalue) {
Image::destroy($i);
}
}
} catch (Exception $e) {
return redirect('home')->withErrors($e->getMessage());
}
return redirect('home');
} else {
return redirect('auth/login');
}
}
示例7: update
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
$this->validate($request, ['title' => 'required', 'caption' => 'required']);
$input = $request->all();
$banner = Banner::findOrFail($id);
$banner->fill($input);
//dd($request->all());
if ($request->hasFile('image')) {
Image::destroy($banner->image_id);
$image = $request->file('image');
$image_name = $image->getClientOriginalName();
$image->move(public_path() . '/images/banners/', $image_name);
$newImage = Image::create(['image_name' => $image_name]);
$banner->image_id = $newImage->id;
}
$banner->save();
return redirect()->route('admin.banner.index');
}
示例8: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
*
* @return Response
*/
public function destroy($id)
{
Image::destroy($id);
Session::flash('flash_message', 'Image deleted!');
return redirect('admin/image');
}