añadir nuevas funcionalidades
This commit is contained in:
36
app/Models/Comment.php
Normal file
36
app/Models/Comment.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
|
||||
class Comment extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'content',
|
||||
'user_id',
|
||||
'document_id',
|
||||
'parent_id',
|
||||
'page',
|
||||
'x',
|
||||
'y'
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function document()
|
||||
{
|
||||
return $this->belongsTo(Document::class);
|
||||
}
|
||||
|
||||
public function replies()
|
||||
{
|
||||
return $this->hasMany(Comment::class, 'parent_id');
|
||||
}
|
||||
}
|
||||
@@ -17,10 +17,11 @@ class Document extends Model
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'status',
|
||||
'project_id',
|
||||
'file_path',
|
||||
'project_id', // Asegurar que está en fillable
|
||||
'folder_id',
|
||||
'current_version_id'
|
||||
'user_id',
|
||||
'status'
|
||||
];
|
||||
|
||||
|
||||
@@ -36,6 +37,7 @@ class Document extends Model
|
||||
return $this->hasMany(Comment::class)->whereNull('parent_id');
|
||||
}
|
||||
|
||||
|
||||
public function createVersion($file)
|
||||
{
|
||||
return $this->versions()->create([
|
||||
|
||||
22
app/Models/DocumentComment.php
Normal file
22
app/Models/DocumentComment.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DocumentComment extends Model
|
||||
{
|
||||
protected $fillable = ['content', 'page', 'x', 'y', 'parent_id'];
|
||||
|
||||
public function user() {
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function children() {
|
||||
return $this->hasMany(DocumentComment::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function parent() {
|
||||
return $this->belongsTo(DocumentComment::class, 'parent_id');
|
||||
}
|
||||
}
|
||||
@@ -10,9 +10,9 @@ class Folder extends Model
|
||||
'name',
|
||||
'parent_id',
|
||||
'project_id',
|
||||
'icon',
|
||||
'color',
|
||||
'description',
|
||||
//'icon',
|
||||
//'color',
|
||||
//'description',
|
||||
];
|
||||
|
||||
public function descendants()
|
||||
|
||||
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
|
||||
@@ -21,9 +22,18 @@ class User extends Authenticatable
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'title',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'username',
|
||||
'email',
|
||||
'password',
|
||||
'phone',
|
||||
'address',
|
||||
'access_start',
|
||||
'access_end',
|
||||
'is_active',
|
||||
'profile_photo_path',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -39,26 +49,25 @@ class User extends Authenticatable
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
* @var list<string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
'is_protected' => 'boolean',
|
||||
];
|
||||
}
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
'access_start' => 'date',
|
||||
'access_end' => 'date',
|
||||
'is_active' => 'boolean'
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the user's initials
|
||||
*/
|
||||
public function initials(): string
|
||||
{
|
||||
return Str::of($this->name)
|
||||
/*return Str::of($this->name)
|
||||
->explode(' ')
|
||||
->map(fn (string $name) => Str::of($name)->substr(0, 1))
|
||||
->implode('');
|
||||
->implode('');*/
|
||||
return Str::of('');
|
||||
}
|
||||
|
||||
public function groups()
|
||||
@@ -89,5 +98,16 @@ class User extends Authenticatable
|
||||
return $group->hasAnyPermission($permissions);
|
||||
});
|
||||
}
|
||||
|
||||
public function getFullNameAttribute()
|
||||
{
|
||||
return "{$this->title} {$this->first_name} {$this->last_name}";
|
||||
}
|
||||
|
||||
// Accesor para la URL completa
|
||||
public function getProfilePhotoUrlAttribute()
|
||||
{
|
||||
return $this->profile_photo ? Storage::url($this->profile_photo) : asset('images/default-user.png');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user