Skip to main content

model


    recipe( 'model' )->with( [
        'name' => '\App\Models\Post',
        'dates' => [ 'created_at', 'updated_at', 'deleted_at' ],
        'relations' => [
            recipe( 'relation' )->with( [
                'name' => 'comments',
                'type' => 'hasMany',
                'model' => '\App\Models\Comment',
            ] )->build(),
            recipe( 'relation' )->with( [
                'name' => 'user',
                'type' => 'belongsTo',
                'model' => '\App\Models\User',
            ] )->build(),
        ],
    ] )->build();

    recipe( 'model' )->with( [
        'name' => '\App\Models\Comment',
        'dates' => [ 'created_at', 'updated_at', 'deleted_at' ],
        'relations' => [
            recipe( 'relation' )->with( [
                'name' => 'post',
                'type' => 'belongsTo',
                'model' => '\App\Models\Post',
            ] )->build(),
            recipe( 'relation' )->with( [
                'name' => 'author',
                'type' => 'belongsTo',
                'model' => '\App\Models\User',
            ] )->build(),
        ],
    ] )->build();

    recipe( 'model' )->with( [ 'hidden' => 'password',
        'name' => '\App\Models\User',
        'dates' => [ 'created_at', 'updated_at', 'deleted_at' ],
        'relations' => [
            recipe( 'relation' )->with( [
                'name' => 'posts',
                'type' => 'hasMany',
                'model' => '\App\Models\Post',
            ] )->build(),
            recipe( 'relation' )->with( [
                'name' => 'comments',
                'type' => 'hasManyThrough',
                'model' => '\App\Models\Comment',
                'through' => '\App\Models\Post',
            ] )->build(),
        ],
    ] )->build();


    recipe( 'exfriend/migration' )->withSchema( base_path( 'recipes/post.json' ) )->build();
    recipe( 'exfriend/migration' )->withSchema( base_path( 'recipes/comment.json' ) )->build();
    recipe( 'exfriend/migration' )->withSchema( 'exfriend/exbox:user.json' )->build();