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


PHP Photo::find方法代码示例

本文整理汇总了PHP中app\Photo::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Photo::find方法的具体用法?PHP Photo::find怎么用?PHP Photo::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Photo的用法示例。


在下文中一共展示了Photo::find方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deletePhoto

 public function deletePhoto(Request $request)
 {
     $photoId = $request->json()->get('id');
     $photo = Photo::find($photoId);
     $photo->delete();
     return Response::json(['result' => 'success'], 200);
 }
开发者ID:reny410,项目名称:backendTPA,代码行数:7,代码来源:ShineController.php

示例2: test_a_photo_has_a_path

 /**
  * A basic test example.
  *
  * @return void
  */
 public function test_a_photo_has_a_path()
 {
     $photo = Photo::create(['path' => '/storage/test.png']);
     $photo = Photo::find(1);
     $path = $photo->path;
     $this->assertequals("/storage/test.png", $path);
 }
开发者ID:ynniswitrin,项目名称:8A-Fotos,代码行数:12,代码来源:PhotoTest.php

示例3: getOp

 /**
  * Get profile photo of user
  */
 function getOp(Request $request)
 {
     $photo = Photo::find($request->get('id'));
     if ($photo instanceof Photo) {
         return self::respond($photo->path);
     } else {
         throw new \Exception();
     }
 }
开发者ID:hboers,项目名称:sample-laravel-app,代码行数:12,代码来源:FileController.php

示例4: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $photo = Photo::find($id);
     $title = $photo->title;
     File::delete('uploads/' . $title);
     File::delete('uploads/thumbs/' . $title);
     $photo->delete();
     return redirect()->back();
 }
开发者ID:nguyentantintb,项目名称:wedding-card,代码行数:15,代码来源:PhotoController.php

示例5: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $photo = Photo::find($id);
     if (!$photo) {
         throw new NotFoundHttpException('no photo found');
     }
     if (!$photo->delete()) {
         throw new FatalErrorException('could not delete photo');
     }
     DB::table('photo_post')->where('photo_id', $id)->delete();
     return response()->json(['status' => 'photo deleted']);
 }
开发者ID:artsoroka,项目名称:shopdrobeapp,代码行数:18,代码来源:PhotoController.php

示例6: insertQuery

 public function insertQuery(Request $request)
 {
     $type = $request->input('type');
     $tag = $request->input('tags');
     $id = $request->input('id');
     $mode = $request->input('mode');
     ////////////////////////////////////
     //mode = 0 edit , mode = 1 insert///
     ////////////////////////////////////
     if ($type == 'events') {
         $validator = Validator::make($request->all(), ['title' => 'required', 'address' => 'required', 'body' => 'required', 'tags' => 'required|array']);
         if ($validator->fails()) {
             return redirect()->back()->withErrors($validator)->withInput()->with(array('errorcode' => 'events', 'tags' => $this->returnTags()));
         } else {
             if ($mode == 1) {
                 $event = new Event();
                 $content = new Content();
             } else {
                 $event = Event::find($id);
                 $content = $event->content;
             }
             $content->title = $request->input('title');
             $event->address = $request->input('address');
             $content->body = $request->input('body');
             $content->type = $type;
             $content->save();
             $start = $request->input('start-day') . "|" . $request->input('start-month') . "|" . $request->input('start-year') . "|" . $request->input('start-hour') . ":" . $request->input('start-minute');
             $end = $request->input('end-day') . "|" . $request->input('end-month') . "|" . $request->input('end-year') . "|" . $request->input('end-hour') . ":" . $request->input('end-minute');
             $event->start = $start;
             $event->end = $end;
             $event->highlight = $request->input('highlight') == NULL ? 0 : 1;
             $files = $request->file('img');
             foreach ($files as $file) {
                 if ($file->isValid()) {
                     $photo = new Photo();
                     $tempName = $file->getClientOriginalName();
                     $extension = explode(".", $tempName);
                     $name = $extension[0] . "-" . time() . "." . $extension[1];
                     $destination = 'upload';
                     $file->move($destination, $name);
                     $photo->path = $destination . "/" . $name;
                     $content->photos()->save($photo);
                 }
             }
             if (!empty($tag)) {
                 foreach ($tag as $insertTag) {
                     $row = Tag::where('title', '=', $insertTag)->first();
                     $content->tags()->save($row);
                 }
             }
             $cat = Category::where('title', '=', $request->input('category'))->first();
             if ($cat != null) {
                 $content->categories()->attach($cat->id);
             }
             $content->event()->save($event);
             return redirect('admin');
         }
     } elseif ($type == 'members') {
         $validator = Validator::make($request->all(), ['firstname' => 'required', 'lastname' => 'required', 'email' => 'required']);
         if ($validator->fails()) {
             return redirect()->back()->withErrors($validator)->withInput()->with(array('errorcode' => 'members', 'tags' => $this->returnTags()));
         } else {
             if ($mode == 1) {
                 $member = new Member();
             } else {
                 $member = Member::find($id);
             }
             $member->firstname = $request->input('firstname');
             $member->lastname = $request->input('lastname');
             $member->email = $request->input('email');
             //$member->password = $request->input('password');
             $member->researchareas = $request->input('researchareas') == NULL ? NULL : $request->input('researchareas');
             $member->industrialareas = $request->input('intery') == NULL ? NULL : $request->input('industry');
             $member->tel = $request->input('telephone') == NULL ? NULL : $request->input('telephone');
             $member->mobile = $request->input('mobile') == NULL ? NULL : $request->input('mobile');
             $member->position = $request->input('position') == NULL ? NULL : $request->input('position');
             $member->googleplus = $request->input('googleplus') == NULL ? NULL : $request->input('pinterest');
             $member->facebook = $request->input('facebook') == NULL ? NULL : $request->input('facebook');
             $member->twitter = $request->input('twitter') == NULL ? NULL : $request->input('instagram');
             $member->linkedin = $request->input('linkedin') == NULL ? NULL : $request->input('linkedin');
             if ($request->hasFile('img')) {
                 $file = $request->file('img');
                 if ($file->isValid()) {
                     $photo = new Photo();
                     $tempName = $file->getClientOriginalName();
                     $extension = explode(".", $tempName);
                     $name = $extension[0] . "-" . time() . "." . $extension[1];
                     $destination = 'upload';
                     $file->move($destination, $name);
                     //$photo->title = $request->input('photoTitle');
                     $photo->path = $destination . "/" . $name;
                     Photo::where("member_id", $member->id)->delete();
                     $member->photo()->save($photo);
                 }
             }
             if ($request->hasFile('cv')) {
                 $file = $request->file('cv');
                 if ($file->isValid()) {
                     $tempName = $file->getClientOriginalName();
                     $extension = explode(".", $tempName);
//.........这里部分代码省略.........
开发者ID:ariiiaaaaan,项目名称:sbu_testlab,代码行数:101,代码来源:AdminController.php

示例7: testMorphOneToManySaveOrder3

 /**
  * @expectedException Illuminate\Database\QueryException
  */
 public function testMorphOneToManySaveOrder3()
 {
     $photo = new Photo();
     $photo->desc = 'photo 4';
     $photo->photoable_id = 0;
     $photo->photoable_type = '';
     $photo->save();
     $id = $photo->id;
     $photo = Photo::find($id);
     $this->assertEquals('photo 4', $photo->desc);
     $phone = new Phone();
     $phone->number = '555';
     $phone->user_id = 3;
     $phone->photos()->save($photo);
     $phone->save();
 }
开发者ID:richarddlu,项目名称:test_eloquent,代码行数:19,代码来源:RelationModelTest.php

示例8: getSlider

 public function getSlider($id, $album = 0)
 {
     $photo = Photo::find($id);
     $photo->slider = ($photo->slider + 1) % 2;
     $photo->save();
     // Show the page
     return redirect($album == 0 ? '/admin/photo' : '/admin/photo/' . $album . '/itemsforalbum');
 }
开发者ID:nickeblewis,项目名称:Laravel-5-Bootstrap-3-Starter-Site,代码行数:8,代码来源:PhotoController.php

示例9: getDelete

 public function getDelete($id)
 {
     $photo = Photo::find($id);
     if (!$photo) {
         return redirect()->back()->withError('Photo not found');
     }
     //First delete the photo
     Croppa::delete(public_path() . '/uploads/' . $photo->image);
     //If foreign keys were not added to pivot table as on delete cascade, we also needed to delete the tags beforehand
     //I'm leaving this here just for reference
     //$photo->tags()->detach();
     $photo->delete();
     return redirect()->back()->withSuccess('Photo deleted successfully!');
 }
开发者ID:hugoleodev,项目名称:WhatTheTag,代码行数:14,代码来源:PhotoController.php

示例10: getDoDelete

 /**
  *
  */
 public function getDoDelete($photo_id)
 {
     $photo = \App\Photo::find($photo_id);
     if (is_null($photo)) {
         \Session::flash('flash_message', 'Photo not found.');
         return redirect('\\photos');
     }
     $photo->delete();
     \Session::flash('flash_message', 'Photo #' . $photo->id . ' was deleted.');
     return redirect('/photos');
 }
开发者ID:emersonFang,项目名称:p4,代码行数:14,代码来源:PhotoController.php

示例11: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $photo = \App\Photo::find($id);
     $photo->delete();
     session()->flash('flash_message', 'Photo Deleted!!!');
     return redirect('');
 }
开发者ID:Gadurp1,项目名称:GetRealClothing,代码行数:13,代码来源:PhotosController.php

示例12: deletePhoto

 public function deletePhoto($id)
 {
     $photo = Photo::find($id);
     $photo->delete();
     return redirect(url('admin/school/' . $photo->school_id))->with('success', 'Slika je obrisana');
 }
开发者ID:rista404,项目名称:vzb,代码行数:6,代码来源:AdminController.php


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