我试图让观察者,当我在表单中创建我的财产/广告时,我转储了一些字符串和信息,但我只是收到成功消息,即财产/广告是在没有转储和信息的情况下创建的。它还将其插入到数据库中。我只是遵循 Laravel 的常规文档。任何帮助表示赞赏。这是我的代码。
属性观察器.php
<?php
namespace App\Observers;
use App\Property;
class PropertyObserver
{
public function created(Property $property)
{
dd('Propertyyyyyyyyyy!!!', $property);
}
public function updated(Property $property)
{
}
public function deleted(Property $property)
{
}
}
应用服务提供者.php
<?php
namespace App\Providers;
use App\Property;
use App\Observers\PropertyObserver;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->publishes([
base_path().'/config/permissions.php' => config_path('permissions.php'),
]);
$this->publishes([
base_path().'/config/roles.php' => config_path('roles.php'),
]);
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Schema::defaultStringLength(191);
$this->mergeConfigFrom(
base_path().'/config/permissions.php', 'permissions'
);
$this->mergeConfigFrom(
base_path().'/config/roles.php', 'roles'
);
Property::observe(PropertyObserver::class);
}
}
函数式编程