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


PHP Picture::find方法代码示例

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


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

示例1: picture

 /**
  * Show hub picture
  *
  * @return Response
  */
 public function picture($id)
 {
     $pic = Picture::find($id);
     if ($pic) {
         return Response::download(storage_path() . "/pictures/" . $pic->name . ".png");
     } else {
         return App::abort(404);
     }
 }
开发者ID:centaurustech,项目名称:musicequity,代码行数:14,代码来源:HubController.php

示例2: profilepicture

 /**
  * Show artist profile picture
  *
  * @return Response
  */
 public function profilepicture($id, $type)
 {
     $pic = Picture::find($id);
     if ($pic) {
         return Response::download(storage_path() . "/pictures/" . $pic->name . "-" . $type . $pic->extension);
     } else {
         return Response::download(storage_path() . "/no-user.png");
     }
 }
开发者ID:centaurustech,项目名称:musicequity,代码行数:14,代码来源:UsersController.php

示例3: Property

 function test_for_has_many()
 {
     $Property =& new Property();
     $this->assertEqual($Property->picture->getType(), 'hasMany');
     $this->assertTrue(is_array($Property->pictures) && count($Property->pictures) === 0);
     $Property->picture->load();
     $this->assertEqual($Property->picture->count(), 0);
     $SeaViews =& new Picture(array('title' => 'Sea views'));
     $Property->picture->add($SeaViews);
     $this->assertEqual($Property->picture->count(), 1);
     $this->assertReference($Property->pictures[0], $SeaViews);
     $Property->picture->add($SeaViews);
     $this->assertEqual($Property->picture->count(), 1);
     $this->assertNull($Property->pictures[0]->get('property_id'));
     $MountainViews =& new Picture(array('title' => 'Mountain views'));
     $this->assertTrue($MountainViews->isNewRecord());
     $Property->picture->add($MountainViews);
     $this->assertEqual($Property->picture->count(), 2);
     $this->assertTrue($Property->save());
     $this->assertFalse($SeaViews->isNewRecord());
     $this->assertFalse($MountainViews->isNewRecord());
     $this->assertEqual($SeaViews->get('property_id'), $Property->getId());
     $this->assertEqual($MountainViews->get('property_id'), $Property->getId());
     $this->assertReference($SeaViews, $Property->pictures[0]);
     $this->assertReference($MountainViews, $Property->pictures[1]);
     $Property =& new Property($Property->getId());
     $Property->picture->load();
     $this->assertEqual($Property->picture->association_id, 'pictures');
     $this->assertEqual($Property->picture->count(), 2);
     $Property->pictures = array();
     $this->assertEqual($Property->picture->count(), 0);
     $Property->picture->load();
     $this->assertEqual($Property->picture->count(), 0);
     $Property->picture->load(true);
     $this->assertEqual($Property->picture->count(), 2);
     $this->assertEqual($Property->pictures[1]->getType(), 'Picture');
     $Property->picture->delete($Property->pictures[1]);
     $this->assertEqual($Property->picture->count(), 1);
     $Property->picture->load(true);
     $this->assertEqual($Property->picture->count(), 1);
     $Property = $Property->find('first');
     $Picture = new Picture();
     $Pictures = $Picture->find();
     $Property->picture->set($Pictures);
     $this->assertEqual($Property->picture->count(), count($Pictures));
     $Property = $Property->find('first');
     $Property->picture->load();
     $this->assertEqual($Property->picture->count(), count($Pictures));
     $Picture = $Picture->find('first');
     $Property->picture->set($Picture);
     $this->assertEqual($Property->picture->count(), 1);
     $this->assertTrue(in_array('pictures', $Property->getAssociatedIds()));
     $Property = $Property->find('first', array('include' => 'pictures'));
     $this->assertIdentical($Property->picture->count(), 1);
     $this->assertEqual($Property->pictures[0]->getId(), $Picture->getId());
     $this->assertTrue($Property->picture->delete($Property->pictures[0]));
     $this->assertIdentical($Property->picture->count(), 0);
     $Property =& $Property->find('first');
     $this->assertIdentical($Property->picture->count(), 0);
     //$this->assertTrue($Property =& $Property->find('first', array('include'=>'pictures')));
     //$this->assertIdentical($Property->picture->count(), 0);
     $Picture =& new Picture();
     $Alicia =& $Picture->create(array('title' => 'Alicia'));
     $Bermi =& $Picture->create(array('title' => 'Bermi'));
     $Hilario =& $Picture->create(array('title' => 'Hilario'));
     $Property->picture->setByIds(array($Alicia->getId(), $Bermi->getId(), $Hilario->getId()));
     $Property->set('description', 'Cool house');
     $this->assertTrue($Property->save());
     $this->assertTrue($Property =& $Property->findFirstBy('description', 'Cool house'));
     $Property->picture->load();
     $this->assertEqual($Property->picture->count(), 3);
     $FoundAlicia = $Property->picture->find('first', array('conditions' => array('title = ?', "Alicia")));
     $this->assertEqual($Alicia->get('title') . $Alicia->getId(), $FoundAlicia->get('title') . $FoundAlicia->getId());
     $FoundPals = $Property->picture->find();
     $this->assertEqual(count($FoundPals), $Property->picture->count());
     $titles = array();
     foreach ($FoundPals as $FoundPal) {
         $titles[] = $FoundPal->get('title');
     }
     sort($titles);
     $this->assertEqual($titles, array('Alicia', 'Bermi', 'Hilario'));
     $this->assertFalse($Property->picture->isEmpty());
     $this->assertEqual($Property->picture->getSize(), 3);
     $this->assertTrue($Property->picture->clear());
     $this->assertTrue($Property->picture->isEmpty());
     $this->assertEqual($Property->picture->getSize(), 0);
     $Property =& new Property();
     $PoolPicture =& $Property->picture->build(array('title' => 'Pool'));
     $this->assertReference($PoolPicture, $Property->pictures[0]);
     $this->assertTrue($Property->pictures[0]->isNewRecord());
     $this->assertEqual($PoolPicture->getType(), 'Picture');
     $Property->set('description', 'Maui Estate');
     $this->assertTrue($Property->save());
     $this->assertTrue($MauiEstate = $Property->findFirstBy('description', 'Maui Estate', array('include' => 'pictures')));
     $this->assertEqual($MauiEstate->pictures[0]->get('title'), 'Pool');
     $Property =& new Property(array('description' => 'Villa Altea'));
     $GardenPicture =& $Property->picture->create(array('title' => 'Garden'));
     $this->assertReference($GardenPicture, $Property->pictures[0]);
     $this->assertTrue($GardenPicture->isNewRecord());
     $Property =& new Property(array('description' => 'Villa Altea'));
//.........这里部分代码省略.........
开发者ID:joeymetal,项目名称:v1,代码行数:101,代码来源:AkHasMany.php

示例4: singlePost

 public function singlePost($id)
 {
     $post = Post::find($id);
     $data['date'] = $this->getBaseDateTime();
     if ($post == null) {
         return null;
     }
     if (Auth::check()) {
         if ($post->type == '0') {
             $post = Post::join('users', 'users.id', '=', 'posts.user_id')->select('posts.*')->where('posts.id', $id)->where('users.disable', '0')->whereType('0')->whereIn('posts.user_id', function ($query) {
                 $query->select('friend_id')->from('friend_list')->whereUserId(Auth::user()->id);
             })->orWhere('posts.user_id', Auth::user()->id)->where('users.disable', '0')->whereType('0')->where('posts.id', $id)->first();
             if ($post == null) {
                 return null;
             }
         }
         //
         $now = Carbon::parse($post->created_at);
         $feeling = DB::table('feelings')->find($post->feeling)->name;
         $following = Following::whereFollowerId(Auth::user()->id)->whereFollowingId($post->user_id)->get()->count();
         $confession = Confession::whereUserId($post->user_id)->first();
         if ($confession) {
             $confess_time = Carbon::parse($confession->created_at);
             $confess_time = $confess_time->diffInHours();
             //$confess_time = $confess_time->diffInSeconds();
             if ($confess_time < 24) {
                 if ($confession->updated_at < $post->created_at) {
                     $confession = $confession->confess;
                 } else {
                     $confession = null;
                 }
             } else {
                 $confession = null;
             }
         }
         $user = User::find($post->user_id);
         $url = Picture::find($user->picture);
         $url = $url->url;
         $text = htmlentities($post->post);
         // 9-2-Start
         $pos = strpos($text, 'watch?v=');
         if ($pos != 0) {
             $pos = $pos + 8;
             $str = substr($text, $pos, 11);
             # code...
         } else {
             $str = null;
         }
         // 9-2-End
         $data['post'] = array('id' => $post->id, 'post' => $text, 'user_id' => $post->user_id, 'img' => asset($url), 'confess' => $confession, 'following' => $following, 'type' => $post->type, 'like' => Like::wherePostId($post->id)->get()->count(), 'dislike' => Dislike::wherePostId($post->id)->get()->count(), 'liked' => Like::wherePostId($post->id)->whereUserId(Auth::user()->id)->get()->count(), 'disliked' => Dislike::wherePostId($post->id)->whereUserId(Auth::user()->id)->get()->count(), 'comment' => Comment::wherePostId($post->id)->get()->count(), 'feeling' => $feeling, 'vidsrc' => $str, 'ago' => $now->diffForHumans());
         $data['notifications'] = $this->getNotification();
         //
     } else {
         if ($post->type == '0') {
             return null;
         }
         //
         $now = Carbon::parse($post->created_at);
         $feeling = DB::table('feelings')->find($post->feeling)->name;
         $following = null;
         $confession = Confession::whereUserId($post->user_id)->first();
         if ($confession) {
             $confess_time = Carbon::parse($confession->created_at);
             $confess_time = $confess_time->diffInHours();
             //$confess_time = $confess_time->diffInSeconds();
             if ($confess_time < 24) {
                 if ($confession->updated_at < $post->created_at) {
                     $confession = $confession->confess;
                 } else {
                     $confession = null;
                 }
             } else {
                 $confession = null;
             }
         }
         $user = User::find($post->user_id);
         $url = Picture::find($user->picture);
         $url = $url->url;
         $text = htmlentities($post->post);
         // 9-2-Start
         $pos = strpos($text, 'watch?v=');
         if ($pos != 0) {
             $pos = $pos + 8;
             $str = substr($text, $pos, 11);
             # code...
         } else {
             $str = null;
         }
         //9-2-End
         $data['post'] = array('id' => $post->id, 'post' => $text, 'user_id' => $post->user_id, 'img' => asset($url), 'confess' => $confession, 'following' => $following, 'type' => $post->type, 'like' => Like::wherePostId($post->id)->get()->count(), 'dislike' => Dislike::wherePostId($post->id)->get()->count(), 'liked' => 0, 'disliked' => 0, 'comment' => Comment::wherePostId($post->id)->get()->count(), 'feeling' => $feeling, 'vidsrc' => $str, 'ago' => $now->diffForHumans());
         //
         $data['notifications'] = ['length' => 0, 'notifications' => null];
     }
     $data['single'] = 1;
     $data['reports'] = Report::get();
     // return json_encode($data['']);
     return View::make('single')->withData($data);
 }
开发者ID:nayeemjoy,项目名称:maskcamp,代码行数:98,代码来源:UsersController.php

示例5: test_clean_up_dependencies

 public function test_clean_up_dependencies()
 {
     $Property = new Property(array('description' => 'Ruins in Matamon'));
     $this->assertTrue($Property->save());
     $South =& $Property->picture->create(array('title' => 'South views'));
     $this->assertReference($South, $Property->pictures[0]);
     $this->assertFalse($South->isNewRecord());
     $pic_id = $South->getId();
     $Property = new Property($Property->getId());
     $this->assertTrue($Property->destroy());
     $Picture = new Picture();
     $this->assertFalse($Picture->find($pic_id));
 }
开发者ID:joeymetal,项目名称:v1,代码行数:13,代码来源:AkHasMany.php

示例6: function

        return Redirect::guest('admin/login');
    }
    if (Auth::check()) {
        if (!Auth::user()->hasRole("admin") && Route::current()->getPath() != "admin/login") {
            return Redirect::guest('admin/login');
        }
    }
});
Route::filter('auth', function () {
    if (Auth::guest()) {
        return Redirect::guest('login');
    }
});
Route::filter('pic_permission', function ($route) {
    $id = $route->getParameter('id');
    $picture = Picture::find($id);
    if (!$picture) {
        App::abort(404);
    }
    // if (Auth::guest() or (!$picture->belongsToUser(Auth::user()) and !Auth::user()->hasAnyRole(array('admin','modirator'))))
    if (Auth::guest() or !($picture->belongsToUser(Auth::user()) or Auth::user()->hasAnyRole(array('admin', 'modirator')))) {
        $page_title = "page 401 :(";
        $article = Article::where('name', '=', '401')->get()->first();
        if (!$article) {
            return Response::view('frontend.article.alternative-401-page', compact('page_title'), 401);
        }
        return Response::view('frontend.article.index', compact('article', 'page_title'), 404);
    }
});
Route::filter('comment_permission', function ($route) {
    $id = $route->getParameter('id');
开发者ID:netfox01,项目名称:exprime,代码行数:31,代码来源:filters.php

示例7: show_art

 /**
  * Returns art by songs id
  *
  * @param $id
  * @return Response
  */
 public function show_art($id)
 {
     $song = Song::find($id);
     $author = User::find($song->artist);
     $pic = Picture::find($author->picture);
     if ($song) {
         if (!empty($song->art)) {
             return Response::download($song->art);
         } else {
             return Response::download(storage_path() . "/pictures/" . $pic->name . "-medium" . $pic->extension);
             //return Response::download(storage_path() . "/cd.png");
         }
     }
 }
开发者ID:centaurustech,项目名称:musicequity,代码行数:20,代码来源:ArtistsController.php

示例8: deleteImage

 public function deleteImage()
 {
     if (!Auth::check()) {
         return Response::json(array('errCode' => 1, 'message' => '请登录'));
     }
     $photo_id = Input::get('photo_id');
     $picture = Picture::find($photo_id);
     if ($picture == null) {
         return Response::json(array('errCode' => 3, 'message' => '照片不存在!'));
     }
     if ($picture->Album->user_id != Auth::user()->id) {
         return Response::json(array('errCode' => 4, 'message' => '[权限禁止]只能删除自己的照片'));
     }
     if (!$picture->delete()) {
         return Response::json(array('errCode' => 2, 'message' => '照片删除失败!'));
     }
     return Response::json(array('errCode' => 0, 'message' => '照片删除成功!'));
 }
开发者ID:Jv-Juven,项目名称:opera-1,代码行数:18,代码来源:UserController.php

示例9: postProcess

 public function postProcess($posts)
 {
     $data = null;
     $i = 0;
     foreach ($posts as $post) {
         $post = Post::find($post->id);
         //if ($i == 5) break;	///////////////////06-May-2015-Ehsan
         $now = Carbon::parse($post->created_at);
         $feeling = DB::table('feelings')->find($post->feeling)->name;
         $following = Following::whereFollowerId(Auth::user()->id)->whereFollowingId($post->user_id)->get()->count();
         $confession = Confession::whereUserId($post->user_id)->first();
         if ($confession) {
             $confess_time = Carbon::parse($confession->created_at);
             $confess_time = $confess_time->diffInHours();
             //$confess_time = $confess_time->diffInSeconds();
             if ($confess_time < 24) {
                 if ($confession->updated_at < $post->created_at) {
                     $confession_view = ConfessionView::whereConfessionId($confession->id)->whereIsValid(1)->get()->count();
                     $confession = ['id' => $confession->id, 'confess' => $confession->confess, 'view' => $confession_view];
                 } else {
                     $confession = null;
                 }
             } else {
                 $confession = null;
             }
         }
         $user = User::find($post->user_id);
         if ($user->disable == 1) {
             continue;
         }
         $url = Picture::find($user->picture);
         $url = $url->url;
         $text = htmlentities($post->post);
         // Youtube Video Searching
         $pos = strpos($text, 'watch?v=');
         if ($pos != 0) {
             $pos = $pos + 8;
             $str = substr($text, $pos, 11);
             # code...
         } else {
             $str = null;
         }
         //
         $name = null;
         if (($post->type == 1 || $post->type == 3) && !$post->hide_name) {
             $user = User::find($post->user_id);
             $name = $user->username;
         }
         $text = preg_replace('/#([a-zA-Z0-9\\x{0980}-\\x{09FF}_])+/u', '<a href="" class="tags">$0</a>', $text);
         /* Eve-26-May-Ehsan */
         $text = preg_replace('#((https?|ftp)://(\\S*?\\.\\S*?))([\\s)\\[\\]{},;"\':<]|\\.\\s|$)#i', '<a target="_blank" href="$1">$1</a>', $text);
         /* !!!!Eve-26-May-Ehsan */
         $text = nl2br($text);
         $text = Emojione::shortnameToImage($text);
         $data[$i++] = array('id' => $post->id, 'post' => $text, 'user_id' => $post->user_id, 'img' => asset($url), 'confess' => $confession, 'following' => $following, 'type' => $post->type, 'like' => Like::wherePostId($post->id)->get()->count(), 'dislike' => Dislike::wherePostId($post->id)->get()->count(), 'liked' => Like::wherePostId($post->id)->whereUserId(Auth::user()->id)->get()->count(), 'disliked' => Dislike::wherePostId($post->id)->whereUserId(Auth::user()->id)->get()->count(), 'comment' => Comment::wherePostId($post->id)->get()->count(), 'feeling' => $feeling, 'vidsrc' => $str, 'name' => $name, 'ago' => $now->diffForHumans());
     }
     return $data;
 }
开发者ID:nayeemjoy,项目名称:maskcamp,代码行数:58,代码来源:AjaxsController.php


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