本文整理汇总了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);
}
示例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);
}
示例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();
}
}
示例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();
}
示例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']);
}
示例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);
//.........这里部分代码省略.........
示例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();
}
示例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');
}
示例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!');
}
示例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');
}
示例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('');
}
示例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');
}