HEX
Server: Apache/2.4.61 (Ubuntu)
System: Linux hosting106 7.0.12-1-pve #1 SMP PREEMPT_DYNAMIC PMX 7.0.12-1 (2026-06-09T21:07Z) x86_64
User: clinicadentalargarate.com (1193)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /home/cursos.ril.es/app/Cursos.php
<?php

namespace App;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Auth;

class Cursos extends Model
{
    protected $table = 'cursos';

    protected $fillable = array('idCategoria', 'fechaFin', 'idProfesor', 'numMax', 'numMin', 'resumen', 'mailAntes','mailDEspues','descripcion','fechasInfo','programa','faq', 'lugar', 'imagen', 'fechaInicio', 'duracion', 'horario', 'precios', 'contenidoHtml', 'slug', 'precios_texto', 'plazas', 'title_seo', 'fecha_texto');

    /**
     * Obtiene los alumnos del curso.
     */
    public function userscursos()
    {
        return $this->hasMany('App\UsersCursos');
    }

    /**
     * Relación con Alumnos
     */
    public function users()
    {
        return $this->belongsToMany('App\User','users_cursos','cursos_id','users_id');
    }


    public function listaesperacursos()
    {
        return $this->hasMany('App\ListaEspera');
    }

    public function interesado() {
        
        foreach ($this->listainteresadoscursos()->get() as $interesado) {

            if ($interesado->users_id == Auth::user()->id) {
                return true;
            }
        }

        return false;
    }

    public function tienePlazas() {

        if ($this->numMax <= $this->userscursos()->count()) {
            return false;
        }

        return true;
    }

    public function listainteresadoscursos()
    {
        return $this->hasMany('App\ListaInteresados');
    }

    public function categoria()
    {
        return $this->belongsTo('App\Categorias', 'idCategoria');
    }

    public function profesor()
    {
        return $this->belongsTo('App\Profesores', 'idProfesor');
    }


    public function terminado() {
        if ($this->fechaInicio < Carbon::now()->format('Y-m-d')) {
            return true;
        }
        return false;
    }

    public function scopeFoto($query) {
        return $query->whereBetween('idCategoria', [6,7]);
    }

    public function scopePlazas($query,$alumnos)
    {
        return $query->where('numMax', '>', count($alumnos));
    }

    public function scopeActivos($query) {
        return $query->where('fechaInicio', '>=', Carbon::now()->format('Y-m-d'));
    }

    public function scropeProximos($query) {
        return $query->where('fechaInicio', '>=', Carbon::now()->addWeek()->format('Y-m-d'));
    }

    public function scopeFinalizados($query) {
        return $query->where('fechaFin', '>', Carbon::now()->format('Y-m-d'));
    }

}