UPDATE: Modo de observar modelos
This commit is contained in:
parent
dcce83efdc
commit
d5ab0079bb
@ -3,7 +3,8 @@
|
||||
* @copyright (c) 2024 Notsoweb Software (https://notsoweb.com) - All Rights Reserved
|
||||
*/
|
||||
|
||||
|
||||
use App\Observers\RoleObserver;
|
||||
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
|
||||
use Notsoweb\LaravelCore\Traits\Models\Extended;
|
||||
use Spatie\Permission\Models\Role as ModelsRole;
|
||||
|
||||
@ -14,6 +15,7 @@
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
#[ObservedBy([RoleObserver::class])]
|
||||
class Role extends ModelsRole
|
||||
{
|
||||
use Extended;
|
||||
|
||||
@ -6,6 +6,8 @@
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use App\Http\Traits\HasProfilePhoto;
|
||||
use App\Http\Traits\IsNotifiable;
|
||||
use App\Observers\UserObserver;
|
||||
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
@ -22,6 +24,7 @@
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
#[ObservedBy([UserObserver::class])]
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use Extended,
|
||||
|
||||
@ -1,37 +0,0 @@
|
||||
<?php namespace App\Providers;
|
||||
/**
|
||||
* @copyright (c) 2024 Notsoweb Software (https://notsoweb.com) - All Rights Reserved
|
||||
*/
|
||||
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use App\Observers\RoleObserver;
|
||||
use App\Observers\UserObserver;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
/**
|
||||
* Observadores de la aplicación
|
||||
*
|
||||
* @author Moisés Cortés C. <moises.cortes@notsoweb.com>
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
class ObserverProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Registrar servicios
|
||||
*/
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Inicializar servicios
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
User::observe([UserObserver::class]);
|
||||
Role::observe([RoleObserver::class]);
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
return [
|
||||
App\Providers\AppServiceProvider::class,
|
||||
App\Providers\ObserverProvider::class,
|
||||
Notsoweb\LaravelCore\ServiceProvider::class,
|
||||
Spatie\Permission\PermissionServiceProvider::class,
|
||||
];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user