本文整理汇总了PHP中Media::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Media::where方法的具体用法?PHP Media::where怎么用?PHP Media::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Media
的用法示例。
在下文中一共展示了Media::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
* @param itemid <=== What?
* @param itemtype
* @param userid
* @param string key
* @return Response
*/
public function store()
{
$itemid = Input::get('itemid');
$itemtype = Input::get('itemtype');
$userid = Input::get('userid');
$usercomment = Input::get('comment');
$key = Input::get('key');
$retVal = array('status' => 'ERR', 'msg' => 'Invalid Session');
try {
$user = \Member::where('session_key', '=', $key)->exists();
if (!$user) {
return Response::json($retVal);
}
$media = \Media::where('_id', '=', $itemid)->exists();
//var_dump($media);
if (!$media) {
$retVal = array('status' => 'ERR', 'msg' => 'Invalid item.');
return Response::json($retVal);
}
$comment = new \Comments();
$comment->itemid = $itemid;
$comment->itemtype = $itemtype;
$comment->userid = $userid;
$comment->comment = $usercomment;
$comment->save();
$retVal = array('status' => 'OK');
return Response::json($retVal);
} catch (ModelNotFoundException $e) {
}
}
示例2: getEditmedias
public function getEditmedias($id, $module_id)
{
$medias = Media::where('category_id', $id)->orderBy('name')->get();
$memberships = Membership::orderBy('rank')->get();
$modMediaMembership = array();
foreach (ModuleMediaMembership::where('module_id', $module_id)->get() as $mmm) {
$modMediaMembership[$mmm->media_id][$mmm->membership_id] = true;
}
return \View::make('redminportal::modules/medias')->with('medias', $medias)->with('memberships', $memberships)->with('modMediaMembership', $modMediaMembership);
}
示例3: getCoverAttribute
public function getCoverAttribute()
{
$cover = Media::where('id', $this->attributes['cover_id'])->get(array('url', 'extension'))->first();
if (!empty($cover->url)) {
$response = $cover->url . "_cover." . $cover->extension;
} else {
$response = "themes/vdomax1.1/images/default-cover.png";
}
return $this->attributes['cover'] = $response;
}
示例4: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
//
$media = \Media::where('status', 'approved')->orderBy('createdDate', 'desc')->get();
for ($i = 0; $i < count($media); $i++) {
$media[$i]->mongoid = $media[$i]->_id;
$media[$i]->token = $media[$i]->_token;
unset($media[$i]->_id);
unset($media[$i]->_token);
unset($media[$i]->thumbnail_url);
unset($media[$i]->large_url);
unset($media[$i]->medium_url);
unset($media[$i]->full_url);
unset($media[$i]->delete_type);
unset($media[$i]->delete_url);
unset($media[$i]->filename);
unset($media[$i]->filesize);
unset($media[$i]->temp_dir);
unset($media[$i]->filetype);
unset($media[$i]->is_image);
unset($media[$i]->is_audio);
unset($media[$i]->is_video);
unset($media[$i]->fileurl);
unset($media[$i]->file_id);
unset($media[$i]->caption);
// non file related
unset($media[$i]->lyric);
unset($media[$i]->files);
$dm = $media[$i]->defaultmedias;
unset($dm['delete_type']);
unset($dm['delete_url']);
unset($dm['temp_dir']);
$media[$i]->defaultmedias = $dm;
foreach ($dm as $k => $v) {
$name = 'media' . str_replace(' ', '', ucwords(str_replace('_', ' ', $k)));
$media[$i]->{$name} = $v;
}
unset($media[$i]->defaultmedias);
$dp = $media[$i]->defaultpictures;
unset($dp['delete_type']);
unset($dp['delete_url']);
unset($dp['temp_dir']);
foreach ($dp as $k => $v) {
$name = 'picture' . str_replace(' ', '', ucwords(str_replace('_', ' ', $k)));
$media[$i]->{$name} = $v;
}
unset($media[$i]->defaultpictures);
$media[$i]->createdDate = date('Y-m-d H:i:s', $media[$i]->createdDate->sec);
$media[$i]->lastUpdate = date('Y-m-d H:i:s', $media[$i]->lastUpdate->sec);
}
return $media;
}
示例5: getMedia
public function getMedia()
{
$response = Media::where('active', '=', '1');
if (Input::get('offset')) {
$reponse = $response->skip(Input::get('offset'));
}
if (Input::get('filter') && Input::get('order')) {
$response = $response->orderBy(Input::get('filter'), Input::get('order'));
} else {
$response = $response->orderBy('created_at', 'desc');
}
if (Input::get('limit')) {
$response = $response->take(Input::get('limit'));
} else {
$response = $response->take($this->default_limit);
}
return Response::json($response->get(), 200);
}
示例6: home
public function home()
{
try {
$settings = Setting::first();
if ($settings) {
$search = Input::get('search');
if (isset($search)) {
$media = Media::where('active', '=', 1)->where('title', 'LIKE', '%' . $search . '%')->orderBy('created_at', 'desc')->paginate(Config::get('site.num_results_per_page'));
} else {
$media = Media::with('media_likes', 'comments')->where('active', '=', 1)->orderBy('created_at', 'desc')->paginate(Config::get('site.num_results_per_page'));
}
$data = array('media' => $media, 'search' => $search);
return View::make('home', $data);
} else {
throw new Exception('settings not set, first install the script');
}
} catch (Exception $e) {
return Redirect::to('install');
}
}
示例7: delete
public function delete($user_id = NULL)
{
$user = $this->prepare_user($user_id);
if ($this->ion_auth->is_admin($user_id)) {
$url = 'manage_admins';
} elseif ($this->ion_auth->is_manager($user_id)) {
$url = 'manage_accounts';
} else {
$url = 'admin_users';
}
if ($this->ion_auth->is_collaborator($user_id)) {
$this->c_user->delete($user);
}
$user_deleted = $this->ion_auth->delete_user($user->id);
if (!$user_deleted) {
$this->addFlash(lang('delete_error', [$this->ion_auth->errors()]));
redirect('admin/admin_users');
}
$sender = $this->get('core.mail.sender');
$sender->sendUserDeleteMail(array('user' => $user));
$access_token = new Access_token();
$access_token->where('user_id', $user->id)->get()->delete_all();
$directory_user = new Directory_User();
$directory_user->where('user_id', $user->id)->get()->delete_all();
$facebook_fanpage = new Facebook_Fanpage();
$facebook_fanpage->where('user_id', $user->id)->get()->delete_all();
$keyword = new Keyword();
$keyword->where('user_id', $user->id)->get();
foreach ($keyword as $k) {
$keyword_rank = new Keyword_rank();
$keyword_rank->where('keyword_id', $k->id)->get()->delete_all();
}
$keyword->delete_all();
$media = new Media();
$media->where('user_id', $user->id)->get()->delete_all();
$post = new Post();
$post->where('user_id', $user->id)->get();
foreach ($post as $p) {
$post_social = new Post_social();
$post_social->where('post_id', $p->id)->get()->delete_all();
}
$post->delete_all();
$review = new Review();
$review->where('user_id', $user->id)->get()->delete_all();
$reviews_notification = new Reviews_notification();
$reviews_notification->where('user_id', $user->id)->get()->delete_all();
$rss_feeds_users = new Rss_feeds_users();
$rss_feeds_users->where('user_id', $user->id)->get()->delete_all();
$social_post = new Social_post();
$social_post->where('user_id', $user->id)->get()->delete_all();
$social_value = new Social_value();
$social_value->where('user_id', $user->id)->get()->delete_all();
$user_additional = new User_additional();
$user_additional->where('user_id', $user->id)->get()->delete_all();
$user_feed = new User_feed();
$user_feed->where('user_id', $user->id)->get()->delete_all();
$user_timezone = new User_timezone();
$user_timezone->where('user_id', $user->id)->get()->delete_all();
$this->addFlash(lang('delete_success'), 'success');
redirect('admin/' . $url);
}
示例8: array
$data = array('media' => $media, 'categories' => Category::all(), 'pages' => Page::all(), 'settings' => Setting::first());
return View::make('Theme::home', $data);
});
Route::get('popular/month', function () {
$media = Media::where('active', '=', '1')->join('media_likes', 'media.id', '=', 'media_likes.media_id')->where('media_likes.created_at', '>=', date('Y-m-d H:i:s', strtotime('-1 month')))->groupBy('media_likes.media_id')->orderBy(DB::raw('COUNT(media_likes.id)'), 'DESC')->select('media.*')->paginate(30);
$data = array('media' => $media, 'categories' => Category::all(), 'pages' => Page::all(), 'settings' => Setting::first());
return View::make('Theme::home', $data);
});
Route::get('popular/year', function () {
$media = Media::where('active', '=', '1')->join('media_likes', 'media.id', '=', 'media_likes.media_id')->where('media_likes.created_at', '>=', date('Y-m-d H:i:s', strtotime('-1 year')))->groupBy('media_likes.media_id')->orderBy(DB::raw('COUNT(media_likes.id)'), 'DESC')->select('media.*')->paginate(30);
$data = array('media' => $media, 'categories' => Category::all(), 'pages' => Page::all(), 'settings' => Setting::first());
return View::make('Theme::home', $data);
});
// ********* TAGS ROUTE ********** //
Route::get('tags/{tag}', function ($tag) {
$media = Media::where('active', '=', 1)->where('tags', 'LIKE', $tag . ',%')->orWhere('tags', 'LIKE', '%,' . $tag . ',%')->orWhere('tags', 'LIKE', '%,' . $tag)->orWhere('tags', '=', $tag)->orderBy('created_at', 'desc')->paginate(Config::get('site.num_results_per_page'));
$data = array('media' => $media, 'tag' => $tag, 'categories' => Category::all(), 'pages' => Page::all(), 'settings' => Setting::first());
return View::make('Theme::home', $data);
});
// ********* CATEGORY ROUTE ********** //
Route::get('category/{category}', 'CategoriesController@index');
// ********** USER AUTHENTICATION ROUTES ********** //
// LOGIN
Route::get('login', function () {
$settings = Setting::first();
$facebook = new Facebook(array('appId' => $settings->fb_key, 'secret' => $settings->fb_secret_key, 'cookie' => true, 'oauth' => true));
$params = array('scope' => 'email', 'redirect_uri' => URL::to("auth/facebook"));
$loginUrl = $facebook->getLoginUrl($params);
$data = array('type' => 'login', 'settings' => $settings, 'facebook' => $loginUrl);
return View::make('Theme::auth', $data);
});
示例9: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($slug)
{
$media = Media::with('media_likes', 'comments')->where('slug', '=', $slug)->first();
if (isset($media)) {
$view_increment = $this->handleViewCount($media->id);
$next = Media::where('active', '=', 1)->where('created_at', '>', date("Y-m-d H:i:s", strtotime($media->created_at)))->first();
$previous = Media::where('active', '=', 1)->where('created_at', '<', date("Y-m-d H:i:s", strtotime($media->created_at)))->orderBy('created_at', 'desc')->first();
$media_next = Media::where('active', '=', 1)->where('created_at', '>=', date("Y-m-d H:i:s", strtotime($media->created_at)))->take(6)->get();
$next_media_count = $media_next->count();
if ($next_media_count < 6) {
$get_prev_results = 6 - $next_media_count;
$media_prev = Media::where('active', '=', 1)->where('created_at', '<', date("Y-m-d H:i:s", strtotime($media->created_at)))->orderBy('created_at', 'DESC')->take($get_prev_results)->get();
} else {
$media_prev = array();
}
$data = array('item' => $media, 'media_next' => $media_next, 'next' => $next, 'previous' => $previous, 'media_prev' => $media_prev, 'view_increment' => $view_increment, 'settings' => Setting::first(), 'categories' => Category::all(), 'pages' => Page::all(), 'single' => true);
return View::make('Theme::media', $data);
} else {
return Redirect::to('/');
}
}
示例10: show
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($slug)
{
$media = $this->media->where('slug', '=', $slug)->first();
if (isset($media)) {
$view_increment = $this->handleViewCount($media->id);
$next = Media::where('active', '=', 1)->where('created_at', '>', date("Y-m-d H:i:s", strtotime($media->created_at)))->first();
$previous = Media::where('active', '=', 1)->where('created_at', '<', date("Y-m-d H:i:s", strtotime($media->created_at)))->orderBy('created_at', 'desc')->first();
$media_next = Media::where('active', '=', 1)->where('created_at', '>=', date("Y-m-d H:i:s", strtotime($media->created_at)))->take(6)->get();
$next_media_count = $media_next->count();
if ($next_media_count < 6) {
$get_prev_results = 6 - $next_media_count;
$media_prev = Media::where('active', '=', 1)->where('created_at', '<', date("Y-m-d H:i:s", strtotime($media->created_at)))->orderBy('created_at', 'DESC')->take($get_prev_results)->get();
} else {
$media_prev = array();
}
$data = array('media' => $media, 'media_next' => $media_next, 'next' => $next, 'previous' => $previous, 'media_prev' => $media_prev, 'view' => 'single', 'view_increment' => $view_increment);
return View::make('media.show', $data);
} else {
return Redirect::to('/');
}
}
示例11: getDelete
public function getDelete($id)
{
// Find the category using the user id
$category = Category::find($id);
// Find if there's any child
$children = Category::where('category_id', $id)->count();
if ($children > 0) {
$errors = new \Illuminate\Support\MessageBag();
$errors->add('deleteError', "The category '" . $category->name . "' cannot be deleted because it has " . $children . " children categories.");
return \Redirect::to('/admin/categories')->withErrors($errors);
}
// Check in use by media
$medias = Media::where('category_id', $id)->get();
if (count($medias) > 0) {
$errors = new \Illuminate\Support\MessageBag();
$errors->add('deleteError', "The category '" . $category->name . "' cannot be deleted because it is in used.");
return \Redirect::to('/admin/categories')->withErrors($errors);
}
// Delete all images first
$category->deleteAllImages();
// Delete the category
$category->delete();
return \Redirect::to('admin/categories');
}
示例12: fire
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
$config = array('host' => 'http://77.247.178.109:9018', 'endpoint' => '/datasrpc/rpc', 'username' => 'datasrpc', 'password' => 'Q8EAxtApHzNmz6UKHBQX');
$hash = $this->option('hash');
$media = Media::where('hash', '=', $hash)->first();
$transmission = new Vohof\Transmission($config);
$getFiles = $transmission->get($media->hash, array('files'));
$files = $getFiles["arguments"]["torrents"][0]["files"];
if (!empty($files)) {
$media->files()->delete();
$media->folders()->delete();
$ignore_first_folder = true;
$id = 1;
$paths = array();
foreach ($files as $file) {
$fd = parse_url($file["name"]);
$path_parts = pathinfo($fd['path']);
$dirs = explode("/", $path_parts['dirname']);
for ($i = 0; $i <= count($dirs); $i++) {
if (isset($dirs[$i]) && $dirs[$i] != '.') {
$full_path = $this->fullpath($dirs, $i);
if (array_key_exists($full_path, $paths)) {
} else {
$paths[$full_path]["id"] = $id;
$paths[$full_path]["name"] = $dirs[$i];
$prev_path = $this->fullpath($dirs, $i - 1);
if (!isset($paths[$prev_path]["id"])) {
$pv_p = 0;
} else {
$pv_p = $paths[$prev_path]["id"];
}
$new_folder = new MediaFlag();
$new_folder->name = $dirs[$i];
$new_folder->folder_id = $id;
$new_folder->in = $pv_p;
$new_folder->media_id = $media->id;
$new_folder->save();
$id++;
}
} elseif (isset($dirs[$i]) && $dirs[$i] == '.') {
//echo $path_parts["basename"].' 0';
$new_file = new MediaLike();
$new_file->path = $file["name"];
$new_file->name = $path_parts["basename"];
$new_file->type = $this->getExt($new_file->path);
$new_file->in = 0;
$new_file->size = $file["length"];
$new_file->media_id = $media->id;
//$like->user_id = Auth::user()->id;
$new_file->save();
$ignore_first_folder = false;
} else {
if (isset($dirs[$i - 1]) && $dirs[$i - 1] != '.') {
$full_path = $this->fullpath($dirs, $i - 1);
//echo $path_parts["basename"].' '.$paths[$full_path]["id"];
$new_file = new MediaLike();
$new_file->path = $file["name"];
$new_file->name = $path_parts["basename"];
$new_file->type = $this->getExt($new_file->path);
$new_file->in = $paths[$full_path]["id"];
$new_file->size = $file["length"];
$new_file->media_id = $media->id;
//$like->user_id = Auth::user()->id;
$new_file->save();
}
}
}
}
$media["ignore_first"] = $ignore_first_folder;
$media->save();
}
$files_local = $media->files();
if (!empty($files_local)) {
$max_file_id = null;
$max_file_size = 0;
foreach ($files_local as $file) {
if ($file->type == "vid" || $file->type == "vid-conv") {
if ($file->size > $max_file_size) {
$max_file_size = $file->size;
$max_file_id = $file->id;
}
}
}
$media->max_file_id = $max_file_id;
$media->save();
foreach ($files_local as $file) {
if ($file->type == "vid" || $file->type == "vid-conv") {
if ($file->id == $max_file_id) {
echo $this->makeThumbs($media->id, $file->id, '/home/mfs/Downloads/transmission/completed/done/' . $media->id . '/' . $file->path, 1);
} else {
echo $this->makeThumbs($media->id, $file->id, '/home/mfs/Downloads/transmission/completed/done/' . $media->id . '/' . $file->path, 13);
}
}
}
}
//.........这里部分代码省略.........
示例13: profile
public function profile($username)
{
$user = User::where('username', '=', $username)->first();
$medias = Media::where('user_id', '=', $user->id)->orderBy('created_at', 'desc')->paginate(Config::get('site.num_results_per_page'));
$data = array('user' => $user, 'media' => $medias);
return View::make('user.index', $data);
}
示例14: delete
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function delete($id)
{
$category = Category::find($id);
$media = Media::where('category_id', '=', $id)->get();
foreach ($media as $single_media) {
$single_media->category_id = 1;
$single_media->save();
}
$category->delete();
return Redirect::to('admin?section=categories')->with(array('note' => Lang::get('lang.delete_success'), 'note_type' => 'success'));
}
示例15: fire
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
$time_start = microtime(true);
$media = Media::where('state', '!=', 'done')->where('state', '!=', 'failed')->where('state', '!=', 'max_pause')->where('state', '!=', 'process')->where('state', '!=', 'fail_free')->where('state', '!=', 'delete')->get();
foreach ($media as $update) {
try {
if ($update->state === "put_pause") {
echo "start";
$url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
$myvars = 'mode=start&hash=' . $update->hash;
$ch = curl_init($url);
$username = 'datalinktunnel';
$password = 'T52UamGTrmCCGn4fJgyq';
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
$torrent_start = json_decode($response, true);
$update->state = "put_start";
$update->save();
}
$now = new DateTime();
$now_stamp = $now->format('Y-m-d H:i:s');
$diff = strtotime($now_stamp) - strtotime($update->featured_at);
$diff_in_minss = $diff / 60;
if ($diff_in_minss > 60 && $update->cat == 1 && $update->featured_at != "0000-00-00 00:00:00") {
$media_users = UserMedia::where('media_id', '=', $update->id)->get();
$del = true;
foreach ($media_users as $media_user) {
$user = User::where('id', '=', $media_user->user_id)->first();
if ($user->category_id == 1) {
} else {
$del = false;
$update->cat = $user->category_id;
$update->save();
}
}
if ($del) {
$url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
$input_xml = '<methodCall><methodName>system.multicall</methodName><params><param><value><array><data><value><struct><member><name>methodName</name><value><string>d.set_custom5</string></value></member><member><name>params</name><value><array><data><value><string>' . $update->hash . '</string></value><value><string>1</string></value></data></array></value></member></struct></value><value><struct><member><name>methodName</name><value><string>d.delete_tied</string></value></member><member><name>params</name><value><array><data><value><string>' . $update->hash . '</string></value></data></array></value></member></struct></value><value><struct><member><name>methodName</name><value><string>d.erase</string></value></member><member><name>params</name><value><array><data><value><string>' . $update->hash . '</string></value></data></array></value></member></struct></value></data></array></value></param></params></methodCall>';
$ch = curl_init($url);
$username = 'datalinktunnel';
$password = 'T52UamGTrmCCGn4fJgyq';
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $input_xml);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
//timeout in seconds
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
$report = new UserFlag();
$report->type = 'check';
$report->media_id = $update->id;
$report->res = 'took more than an hour' . $response;
$report->save();
$update->state = 'fail_free';
$update->save();
$user_report = UserFlag::where('media_id', '=', $update->id)->where('type', '=', 'error')->first();
if (!isset($user_report->id)) {
$report = new UserFlag();
$report->type = 'error';
$report->media_id = $update->id;
$report->res = $response;
$report->save();
}
}
} else {
$url = 'http://s01.okaydrive.com/rt/plugins/httprpc/action.php';
$myvars = 'mode=list-get&hash=' . $update->hash;
$ch = curl_init($url);
$username = 'datalinktunnel';
$password = 'T52UamGTrmCCGn4fJgyq';
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
//timeout in seconds
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
$tor = json_decode($response, true);
if (count($tor != 0) && $tor != false) {
echo $tor[0];
echo "files begin";
if ($update->files()->count() == 0 && $update->file_try < 3 && $update->state == "downloading" || $update->files()->count() == 0 && $update->file_try == 3 && $update->state == "downloading" && $this->percent($tor[9], $tor[6]) > 0) {
echo "files";
if ($tor[3] != 0) {
//.........这里部分代码省略.........