コード例 #1
0
 function getProductions($slug)
 {
     $category = Term::where(Term::ATTR_SLUG, $slug)->get()[0];
     //Obtiene la cantidad total de producciones asociadas a la categoria
     $cant = Term::findOrNew($category->id)->productions()->count();
     return view("frontend/contents/production/category")->with("category", $category)->with("cant", $cant);
 }
コード例 #2
0
ファイル: Term.php プロジェクト: jhospina/Project-Egolas
 /** Busca un termino por su nombre, de lo contrario retorna Null
  * 
  * @param type $name
  * @return type
  */
 static function searchByName($name)
 {
     $terms = Term::where(Term::ATTR_NAME, ucfirst(strtolower($name)))->get();
     if (!count($terms) > 0) {
         return null;
     }
     foreach ($terms as $term) {
         return $term;
     }
 }
コード例 #3
0
 public function getBrowser()
 {
     if (!Auth::check()) {
         return redirect("user/auth/login?redirect_to=" . url("browser"));
     }
     //Obtiene las 30 ultimas produccion agregadas
     $productions = DB::select("SELECT productions.id FROM chapters,productions WHERE chapters.production_id=productions.id and productions.state='" . Production::STATE_ACTIVE . "' GROUP BY chapters.production_id ORDER BY chapters.id DESC LIMIT 0,30 ");
     $categories = Term::orderBy(Term::ATTR_MOTE, "ASC")->get();
     return view("frontend/contents/gen/browser")->with("productions", $productions)->with("categories", $categories);
 }
コード例 #4
0
ファイル: Taxonomy.php プロジェクト: jhospina/Project-Egolas
 /** Obtiene todos los terminos de una taxonomida dada por el id de la taxonomia
  * 
  * @param type $taxonomy_id
  * @return type
  */
 public static function getAllTerms($taxonomy_id)
 {
     return is_numeric($taxonomy_id) ? Term::where(Term::ATTR_TAXONOMY_ID, $taxonomy_id)->get() : null;
 }
コード例 #5
0
 function ajax_getProductionsByCategory(Request $request)
 {
     if (!$request->ajax()) {
         return json_encode(array());
     }
     $data = $request->all();
     $cat_id = $data["category_id"];
     $skip = $data["skip"];
     $filtered = isset($data["filtered"]) && $data["filtered"] == "true" ? true : false;
     $productions = $filtered ? Term::findOrNew($cat_id)->productions()->where(Production::ATTR_STATE, Production::STATE_ACTIVE)->orderBy("state", "ASC")->skip($skip)->take(72)->groupBy("id")->get() : Term::findOrNew($cat_id)->productions()->orderBy("state", "ASC")->skip($skip)->take(72)->groupBy("id")->get();
     $response = array();
     if ($skip == 0) {
         $total_productions = $filtered ? Term::findOrNew($cat_id)->productions()->where(Production::ATTR_STATE, Production::STATE_ACTIVE)->count() : Term::findOrNew($cat_id)->productions()->count();
     }
     foreach ($productions as $production) {
         $data_production = array("html" => Production::getVisualHtml($production));
         if ($skip == 0) {
             $data_production["total"] = $total_productions;
         }
         $response[] = $data_production;
     }
     if (count($productions) == 0) {
         $response[] = array("total" => 0);
     }
     return json_encode($response);
 }
コード例 #6
0
<?php

use App\System\Models\Term;
use App\System\Library\Detection\MobileDetect;
use App\System\Models\User;
$detect = new MobileDetect();
$categories = Term::orderBy(Term::ATTR_NAME, "ASC")->get();
?>
<nav class="navbar navbar-inverse" id="navbar">
    <div class="navbar-header">
        <a class="navbar-brand" href="{{URL::to("")}}">
            <img class="img-rounded" id="logo" src="{{URL::to("assets/images/logo.png")}}">
        </a>
    </div>
    <div id="nav-info" class="collapse navbar-collapse">
        @if(Auth::check() && !$detect->isMobile() && !$detect->isTablet())
        <ul class="nav navbar-nav" id="explore-menu">
            <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Explorar <span class="caret"></span></a>
                <ul class="dropdown-menu">
                    @foreach($categories as $category)
                    <li><a href="{{URL::to("category/".$category->slug)}}"><span class="glyphicon glyphicon-film"></span> {{ucfirst($category->mote)}}</a></li>
                    @endforeach
                </ul>
            </li>
        </ul>
        @endif
        <ul class="nav navbar-nav navbar-right" id="bar-user">
            @if(Auth::check())

            @if(!$detect->isMobile() && !$detect->isTablet())
コード例 #7
0
 function save()
 {
     if (!$this->validate()) {
         return null;
     }
     $production = new Production();
     $production->title = $this->getTitle();
     $production->title_original = $this->getTitle_original();
     $production->year = $this->getYear();
     $production->slug = $this->getSlug();
     $production->description = $this->getDescription();
     $production->state = is_null($this->getRating_rel()) ? Production::STATE_COMING_SOON : Production::STATE_IN_WAIT;
     $production->rating_rel = $this->getRating_rel();
     $production->duration = $this->getDuration();
     $production->image = $this->getImage();
     $production->poster = $this->poster;
     $production->save();
     //CATEGORIAS DE LA PRODUCCION
     $categories = $this->categories;
     foreach ($categories as $category) {
         //Verifica si ya existe la categoria, si no existe la crea y la asigna a la produccion
         $cat = Term::searchByName($category);
         if (is_null($term = $cat)) {
             $term = new Term();
             $term->name = ucfirst(strtolower($category));
             $term->taxonomy_id = Production::TAXONOMY_ID;
             $term->slug = Util::createSlug($category);
             $term->save();
         }
         $production->terms()->attach($term->id);
     }
     //Relaciona un director con la producción a uno existente o lo crea sin o existe
     $director = $this->getDirector();
     $staff_director = is_null($person = Person::searchByName($director[0])) ? new Person() : $person;
     $staff_director->name = $director[0];
     $staff_director->slug = Util::createSlug($director[0]);
     $staff_director->save();
     if (count(DB::select("SELECT * FROM staff WHERE production_id='" . $production->id . "' && person_id='" . $staff_director->id . "'")) == 0) {
         $staff_director->productions()->attach($production->id, array(Person::ATTR_PIVOT_ROLE => Person::ROLE_DIRECTOR));
     }
     //Determina si el nombre del director se encuentra en cola para actualización, si no lo esta, lo agrega.
     if (is_null(QueuePersons::searchByNameInQueue($director[0]))) {
         $queue = new QueuePersons();
         $queue->person_id = $staff_director->id;
         $queue->name = $director[0];
         $queue->link = $director[1];
         $queue->date_creation = DateUtil::getCurrentTime();
         $queue->save();
     }
     //Relaciona los actores con la produccion a uno existente o lo crea sino existe
     $actors = $this->actors;
     foreach ($actors as $actor) {
         if (is_null($actor[0]) || !isset($actor[0]) || strlen($actor[0]) == 0) {
             continue;
         }
         $staff_actor = is_null($person = Person::searchByName($actor[0])) ? new Person() : $person;
         $staff_actor->name = $actor[0];
         $staff_actor->slug = Util::createSlug($actor[0]);
         $staff_actor->save();
         if (count(DB::select("SELECT * FROM staff WHERE production_id='" . $production->id . "' && person_id='" . $staff_actor->id . "'")) == 0) {
             $staff_actor->productions()->attach($production->id, array(Person::ATTR_PIVOT_ROLE => Person::ROLE_ACTOR));
         }
         //Determina si el nombre del actor/actriz se encuentra en cola para actualización, si no lo esta, lo agrega.
         if (is_null(QueuePersons::searchByNameInQueue($actor[0]))) {
             $queue = new QueuePersons();
             $queue->person_id = $staff_actor->id;
             $queue->name = $actor[0];
             $queue->link = $actor[1];
             $queue->date_creation = DateUtil::getCurrentTime();
             $queue->save();
         }
     }
     return $production->id;
 }