当前位置: 首页>>代码示例>>PHP>>正文


PHP Image::destroy方法代码示例

本文整理汇总了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!";
 }
开发者ID:deferdie,项目名称:tweet,代码行数:9,代码来源:fileManagerController.php

示例2: updateImage

 public function updateImage(Request $request)
 {
     $product = Product::find($request->prodid);
     Image::destroy($request->imageid);
     return response()->json('true');
 }
开发者ID:axicraw,项目名称:tropara,代码行数:6,代码来源:ProductController.php

示例3: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Image::destroy($id);
     return redirect('posts');
 }
开发者ID:BQuiroga,项目名称:finalSis,代码行数:11,代码来源:ImagesController.php

示例4: destroy

 public function destroy($id)
 {
     Image::destroy($id);
     return \Redirect::back()->withErrors('Image #' . $id . ' was deleted');
 }
开发者ID:slopedoo,项目名称:laravel-5,代码行数:5,代码来源:ImagesController.php

示例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.');
 }
开发者ID:phumaster,项目名称:uploadImage,代码行数:40,代码来源:AlbumController.php

示例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');
     }
 }
开发者ID:beruche,项目名称:assignment2,代码行数:85,代码来源:HomeController.php

示例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');
 }
开发者ID:axicraw,项目名称:tropara,代码行数:26,代码来源:BannersController.php

示例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');
 }
开发者ID:wilderguzman,项目名称:lugrawibe,代码行数:13,代码来源:ImageController.php


注:本文中的app\Image::destroy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。