PHP code example of haokeed / laravel-extend-database

1. Go to this page and download the library: Download haokeed/laravel-extend-database library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

haokeed / laravel-extend-database example snippets


Model::where('id', '1')->update([
  'name' => 'laravel'
]);

use Illuminate\Database\Eloquent\Model;
use Haokeed\LaravelExtend\Database\Eloquent\SEvents;

class Category extends Model
{
    use SEvents;
}



namespace Haokeed\LaravelShop\Data\Goods\Models;

use Illuminate\Database\Eloquent\Model as  laravelModel;
use Haokeed\LaravelExtend\Database\Eloquent\SEvents;


class Model extends laravelModel
{
    use SEvents;

}




namespace Haokeed\LaravelShop\Data\Goods\Providers;

use Illuminate\Support\ServiceProvider;
use Haokeed\LaravelShop\Data\Goods\Models\Model;

class GoodsServiceProvider extends ServiceProvider
{
    public function boot()
    {
        Model::observe();

    }
}


//  /Users/sunsheng/Documents/wwwroot/haokeed/laravel-shop/src/Data/Goods/Config/goods.php
return [
    'database' => [
        'observes' => [
            // 批量添加关注者
            // 以后只要有对应的Observer就直接可以添加在这里了
            'Category' => 'CategoryObserver'
        ],
    ]


];