coursework tasks 1 to 10
This commit is contained in:
23
app/Models/Booking.php
Normal file
23
app/Models/Booking.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
// бронирование ĸлиентов
|
||||
class Booking extends Model {
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'bookings';
|
||||
|
||||
protected $fillable = [
|
||||
'bookingnumber',
|
||||
'client_id',
|
||||
'employee_id',
|
||||
'service_id',
|
||||
'bookingdate',
|
||||
'starttime',
|
||||
'endtime',
|
||||
'status',
|
||||
'cancelledby',
|
||||
'cancelreason'
|
||||
];
|
||||
}
|
||||
10
app/Models/EmployeeAvailability.php
Normal file
10
app/Models/EmployeeAvailability.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?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'];
|
||||
}
|
||||
@@ -2,9 +2,24 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Services extends Model
|
||||
class Services extends Model // услуги ĸлининга
|
||||
{
|
||||
//
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'description',
|
||||
'durationminutes',
|
||||
'price',
|
||||
'isactive',
|
||||
];
|
||||
|
||||
// Простая связь с bookings, если нужно
|
||||
public function bookings()
|
||||
{
|
||||
return $this->hasMany(Booking::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,43 +2,27 @@
|
||||
|
||||
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
|
||||
class User extends Authenticatable // все пользователи системы
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasApiTokens, HasFactory, Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
'role',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
@@ -46,4 +30,16 @@ class User extends Authenticatable
|
||||
'password' => 'hashed',
|
||||
];
|
||||
}
|
||||
|
||||
// Проверяет админ или сотрудник
|
||||
public function isEmployeeOrAdmin()
|
||||
{
|
||||
return $this->role == 'employee' || $this->role == 'admin';
|
||||
}
|
||||
|
||||
// Для запросов - все сотрудники и админы
|
||||
public static function scopeEmployeeOrAdmin($query)
|
||||
{
|
||||
return $query->whereIn('role', ['employee', 'admin']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user