- Added authentication controllers (Login, Register) - Added UserController for user profile management - Added VideoController with full CRUD operations - Added Video model with relationships (user, likes, views) - Added User model enhancements (avatar, video relationships) - Added database migrations for video_likes, video_views, user_avatar, video_visibility - Added CompressVideoJob for video processing - Added VideoUploaded mail notification - Added authentication routes - Updated web routes with video and user routes - Added layout templates (app, plain, partials) - Added user views (profile, settings, channel, history, liked) - Added video views (create, edit, index, show) - Added email templates
57 lines
1.2 KiB
PHP
Executable File
57 lines
1.2 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Laravel\Sanctum\HasApiTokens;
|
|
|
|
class User extends Authenticatable
|
|
{
|
|
use HasApiTokens, HasFactory, Notifiable;
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'email',
|
|
'password',
|
|
'avatar',
|
|
];
|
|
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
];
|
|
|
|
protected $casts = [
|
|
'email_verified_at' => 'datetime',
|
|
'password' => 'hashed',
|
|
];
|
|
|
|
// Relationships
|
|
public function videos()
|
|
{
|
|
return $this->hasMany(Video::class);
|
|
}
|
|
|
|
public function likes()
|
|
{
|
|
return $this->belongsToMany(Video::class, 'video_likes')->withTimestamps();
|
|
}
|
|
|
|
public function views()
|
|
{
|
|
return $this->belongsToMany(Video::class, 'video_views')->withTimestamps();
|
|
}
|
|
|
|
public function getAvatarUrlAttribute()
|
|
{
|
|
if ($this->avatar) {
|
|
return asset('storage/avatars/' . $this->avatar);
|
|
}
|
|
return 'https://i.pravatar.cc/150?u=' . $this->id;
|
|
}
|
|
}
|
|
|