本文整理汇总了PHP中app\Image::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::find方法的具体用法?PHP Image::find怎么用?PHP Image::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Image
的用法示例。
在下文中一共展示了Image::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
/**
* Update a minifig
* @access public
* @param int $id
* @param MinifigRequest $request
*/
public function update($id, MinifigRequest $request)
{
$minifig = Minifig::find($id);
$minifig->name = $request->name;
$minifig->set_id = $request->set_id;
$minifig->save();
if ($request->images_to_delete) {
foreach ($request->images_to_delete as $id_image) {
$image = Image::find($id_image);
$image->delete();
}
}
$files = $request->file('files');
if (count($files) > 0) {
foreach ($files as $file) {
if ($file) {
$filename = sha1(rand(1, 100000) . time()) . '.' . $file->guessExtension();
$file->move($this->uploadpath, $filename);
Image::create(['minifig_id' => $id, 'filename' => $filename]);
}
}
}
$request->session()->flash('msg', 'Minifig saved');
return redirect()->action('MinifigController@index');
}
示例2: show
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
$image = Image::find($id)->get();
# return view("image/show",['img'=>$image]);
return Redirect::to('/home');
}
示例3: updateText
public function updateText(Request $request)
{
$id = $request->get('id');
$image = Image::find($id);
$image->text = $request->get('text');
$image->save();
exit;
}
示例4: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$image = Image::find($id);
$minifig = $image->minifig;
$image->delete();
Session::flash('msg', 'Successfully deleted');
return redirect()->action('MinifigController@show', ['id' => $minifig->id]);
}
示例5: 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!";
}
示例6: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$data = Image::find($id);
if ($data) {
return view('forone::' . $this->uri . "/edit", compact('data'));
} else {
return $this->redirectWithError('data not found.');
}
}
示例7: removeClosedImages
public function removeClosedImages($closedImages)
{
foreach ($closedImages as $image) {
$propertyImage = \App\Image::find($image->id);
if ($propertyImage) {
$propertyImage->delete();
}
dispatch((new KillImageFromDisk($image->dataUri))->onQueue('killImage'));
}
}
示例8: index
/**
* Handles displaying an image on a request.
*
* @param $hash
* @return mixed
* @throws \App\Exceptions\MissingImageException
*/
public function index($hash)
{
if (is_numeric($hash)) {
throw new AccessDeniedException('You should not access an image by it\'s ID.');
}
$hash = $this->stripExtension($hash);
$id = $this->hash->decode($hash);
$image = Image::find($id);
return response($image->image, 200)->header('Content-Type', 'image/png');
}
示例9: 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)
{
if (Auth::check()) {
$image = Image::find($id);
$image->title = $request->input('title');
$image->description = $request->input('description');
$image->item_id = $request->input('itemid');
$image->save();
return $image;
}
}
示例10: postMove
public function postMove()
{
$rules = array('new_album' => 'required|numeric|exists:albums,id', 'photo' => 'required|numeric|exists:images,id');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::route('index');
}
$image = Image::find(Input::get('photo'));
$image->album_id = Input::get('new_album');
$image->save();
return Redirect::route('show_album', array('id' => Input::get('new_album')));
}
示例11: apprecier
public function apprecier($id_image, Request $request)
{
if (!is_numeric($id_image) || !Image::find($id_image)) {
return response()->json(['response' => 'ERREUR.']);
}
if (Auth::user()->aime($id_image)) {
DB::table('apprecie')->where(['id_utilisateur' => Auth::user()->id, 'id_image' => $id_image], false)->delete();
return response()->json(['response' => 'doitUnlike']);
} else {
DB::table('apprecie')->insert(['id_utilisateur' => Auth::user()->id, 'id_image' => $id_image]);
return response()->json(['response' => 'doitLike']);
}
}
示例12: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
if ($this->option('all')) {
foreach (Image::all() as $image) {
$image->regenerate();
}
} elseif ($this->argument('image')) {
$image = Image::find($this->argument('image'));
if (count($image)) {
$image->regenerate();
}
}
}
示例13: removeUnrelatedImages
public function removeUnrelatedImages()
{
$skip = 0;
$removeArray = [];
do {
$images = \App\Image::whereDoesntHave('property')->take(100)->skip($skip)->get();
foreach ($images as $imageKey => $image) {
\App\Image::find($image->id)->delete();
dispatch((new KillImageFromDisk($image->dataUri))->onQueue('killImage'));
$removeArray[] = $image->dataUri;
}
\Storage::delete($removeArray);
$skip += 100;
} while ($images->isEmpty() == false);
}
示例14: rules
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
//This id is passed by the controller that calls the request class
$image = Image::find($this->id);
switch ($this->method()) {
case 'GET':
case 'DELETE':
return [];
case 'POST':
return ['name' => 'required|unique:images,name', 'type' => 'required', 'order' => 'numeric', 'image' => 'required|image|mimes:jpeg,bmp,png', 'link' => 'string'];
case 'PUT':
case 'PATCH':
return ['name' => 'required|unique:images,name,' . $image->id, 'type' => 'required', 'order' => 'numeric', 'image' => 'image|mimes:jpeg,bmp,png', 'link' => 'string'];
default:
break;
}
}
示例15: validation
public function validation(AdminRequest $request)
{
foreach ($request->all() as $element => $coche) {
// On vérifie si l'image souhaite être envoyée ou non
// En cas d'autre réponse, on ignore et l'image reste soumise à validation ;-)
if (starts_with($element, 'radio')) {
switch ($coche) {
case 'envoi_oui':
Image::find(substr($element, 5))->est_gardee(true);
break;
case 'envoi_non':
Image::find(substr($element, 5))->est_gardee(false);
break;
}
}
}
return Redirect::to('admin');
}