commit 12.01

This commit is contained in:
Владимир
2026-01-12 14:25:15 +00:00
parent 36084ba590
commit ae5ab2554b
26 changed files with 1116 additions and 1083 deletions

View File

@@ -1,39 +1,42 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
// бронирование клиентов
class Booking extends Model {
class Booking extends Model
{
use HasFactory;
protected $table = 'bookings';
protected $fillable = [
'bookingnumber',
'booking_number',
'client_id',
'employee_id',
'service_id',
'bookingdate',
'starttime',
'endtime',
'booking_date',
'start_time',
'end_time',
'status',
'cancelledby',
'cancelreason'
'cancelled_by',
'cancel_reason'
];
// списки броней
public function service()
{
return $this->belongsTo(Services::class);
}
// Связь с клиентом
public function client()
{
return $this->belongsTo(User::class, 'client_id');
}
// Связь со сотрудником
public function employee()
{
return $this->belongsTo(User::class, 'employee_id');
}
}
// Связь с услугой
public function service()
{
return $this->belongsTo(Service::class);
}
}

View File

@@ -1,10 +1,16 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
// расписание сотрудниĸов
class EmployeeAvailability extends Model {
use HasFactory;
protected $table = 'employee_availabilities';
protected $fillable = ['employee_id','date','starttime','endtime','isavailable'];
}
class EmployeeAvailability extends Model
{
protected $fillable = [
'employee_id',
'date',
'start_time',
'end_time',
'is_available'
];
}

View File

@@ -2,24 +2,24 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class Services extends Model // услуги ĸлининга
class Service extends Model
{
use HasFactory;
protected $fillable = [
'name',
'description',
'durationminutes',
'duration_minutes',
'price',
'isactive',
'is_active'
];
// Простая связь с bookings, если нужно
// Связь с бронированиями
public function bookings()
{
return $this->hasMany(Booking::class);
}
}
}

View File

@@ -2,44 +2,24 @@
namespace App\Models;
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 // все пользователи системы
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable;
use HasApiTokens, Notifiable;
protected $fillable = [
'name',
'email',
'password',
'role',
'role',
'phone'
];
protected $hidden = [
'password',
'remember_token',
];
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
// Проверяет админ или сотрудник
public function isEmployeeOrAdmin()
{
return $this->role == 'employee' || $this->role == 'admin';
}
// Для запросов - все сотрудники и админы
public static function scopeEmployeeOrAdmin($query)
{
return $query->whereIn('role', ['employee', 'admin']);
}
}
}