first change

This commit is contained in:
2025-07-27 17:40:56 +05:45
commit f8b9a6725b
3152 changed files with 229528 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
<?php
namespace App\Models\Scopes;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Scope;
use Illuminate\Support\Facades\Auth;
class CreatedByScope implements Scope
{
/**
* Apply the scope to a given Eloquent query builder.
*/
public function apply(Builder $builder, Model $model): void
{
if (auth()->user()->hasRole('admin')) {
//
}
if (auth()->user()->hasRole('employee')) {
$user = Auth::user();
$builder->where($model->getTable() . '.employee_id', $user->employee_id);
}
}
}

76
app/Models/User.php Normal file
View File

@@ -0,0 +1,76 @@
<?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 Modules\Employee\Models\Employee;
use Spatie\Permission\Traits\HasRoles;
class User extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory, Notifiable, HasRoles;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
'can_login',
'active_sidebar',
'order'
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
public function canLogin(): bool
{
return $this->can_login;
}
public function getRoles()
{
return $this->roles->map(function ($role) {
return "<span class='badge bg-primary p-1'>{$role->name}</span>";
})->implode(' ');
}
public function employee()
{
return $this->belongsTo(Employee::class, "user_id");
}
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
'can_login' => 'boolean',
];
}
public static function getFillableFields()
{
return (new static())->getFillable();
}
}