Primer commit proyecto Laravel
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Area extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public function areas(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Role::class);
|
||||
}
|
||||
|
||||
public function existe($request = null)
|
||||
{
|
||||
if (!$request) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->areas()
|
||||
->wherePivot('role_id', $request)
|
||||
->exists();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Campan extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Carrera extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public function carreraMaterial() : BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Material::class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Concepto extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public function planConceptos() : BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Plane::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Duration extends Model
|
||||
{
|
||||
protected $guarded=[];
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Material extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
public function carreraMaterial() : BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Carrera::class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Medio extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Plantel;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Nivel extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public function nivelPlantel() : BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Plantel::class)->withPivot('plantel_id');
|
||||
}
|
||||
|
||||
public function existe($plantelId = null)
|
||||
{
|
||||
if (!$plantelId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->nivelPlantel()
|
||||
->wherePivot('plantel_id', $plantelId)
|
||||
->exists();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Note extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Pago extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Plan extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public function planesPlantel() : BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Plantel::class)->withPivot('plantel_id');
|
||||
}
|
||||
|
||||
public function existe($plantelId = null)
|
||||
{
|
||||
if (!$plantelId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->planesPlantel()
|
||||
->wherePivot('plantel_id', $plantelId)
|
||||
->exists();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Plane extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public function planPlantel() : BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Plantel::class)->withPivot('plantel_id');
|
||||
}
|
||||
|
||||
public function existe($plantelId = null)
|
||||
{
|
||||
if (!$plantelId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->planPlantel()
|
||||
->wherePivot('plantel_id', $plantelId)
|
||||
->exists();
|
||||
}
|
||||
|
||||
public function conceptos(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Concepto::class)
|
||||
->orderBy('conceptos.tipo', 'asc')
|
||||
->orderBy('conceptos.fecha_pago', 'asc');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Plantel extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public function planesPlantel() : BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Plan::class);
|
||||
}
|
||||
|
||||
public function planPlantel() : BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Plane::class);
|
||||
}
|
||||
|
||||
public function plantelUsuarios() : BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(User::class);
|
||||
}
|
||||
|
||||
public function nivelPlantel() : BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Nivel::class);
|
||||
}
|
||||
|
||||
public function turnoPlantel() : BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Turno::class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Plantel;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Prospecto extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public function plantelUsuarios(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Plantel::class);
|
||||
}
|
||||
|
||||
public function existe($plantelId): bool
|
||||
{
|
||||
return $this->plantelUsuarios()
|
||||
->where('plantels.id', $plantelId)
|
||||
->exists();
|
||||
}
|
||||
|
||||
public function prospectos() : BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(User::class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Ticket extends Model
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TipoConcepto extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Plantel;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
|
||||
class Turno extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public function turnoPlantel() : BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Plantel::class)->withPivot('plantel_id');
|
||||
}
|
||||
|
||||
public function existe($plantelId = null)
|
||||
{
|
||||
if (!$plantelId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->turnoPlantel()
|
||||
->wherePivot('plantel_id', $plantelId)
|
||||
->exists();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use Laravel\Jetstream\HasProfilePhoto;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Fortify\TwoFactorAuthenticatable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use HasApiTokens;
|
||||
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory;
|
||||
use HasProfilePhoto;
|
||||
use Notifiable;
|
||||
use TwoFactorAuthenticatable;
|
||||
use HasRoles;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'telefono',
|
||||
'direccion',
|
||||
'plantel',
|
||||
'password',
|
||||
'status',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
'two_factor_recovery_codes',
|
||||
'two_factor_secret',
|
||||
'status',
|
||||
];
|
||||
|
||||
/**
|
||||
* The accessors to append to the model's array form.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $appends = [
|
||||
'profile_photo_url',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
// public function note() : HasOne
|
||||
// {
|
||||
// //esta funcion es para retornar la relacion de un usario que contenga notas
|
||||
// return $this->hasOne(Note::class);
|
||||
// }
|
||||
|
||||
public function notes() : HasMany
|
||||
{
|
||||
return $this->hasMany(Note::class);
|
||||
}
|
||||
|
||||
public function pagos() : HasMany
|
||||
{
|
||||
return $this->hasMany(Pago::class);
|
||||
}
|
||||
|
||||
public function plantelUsuarios() : BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Plantel::class)->withPivot('plantel_id');
|
||||
}
|
||||
|
||||
public function existe($request = null)
|
||||
{
|
||||
if (!$request) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->plantelUsuarios()
|
||||
->wherePivot('plantel_id', $request)
|
||||
->exists();
|
||||
}
|
||||
|
||||
|
||||
public function prospectos() : BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Prospecto::class);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user