PHP code example of based / laravel-fluent

1. Go to this page and download the library: Download based/laravel-fluent 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/ */

    

based / laravel-fluent example snippets




/**
 * @property Collection $features
 * @property float $price
 * @property int $available
 */
class Product extends Model
{
    protected $casts = [
        'features' => 'collection',
        'price' => 'float',
        'available' => 'integer',
    ];
}



class Product extends Model
{
    use Fluent;

    public Collection $features;
    public float $price;
    public int $available;
}



class User extends Model
{
    use Fluent;
}



class Order extends Model
{
    use Fluent;

    public int $amount;
    public Carbon $expires_at;

    #[AsDecimal(2)]
    public float $total;

    #[Cast('encrypted:array')]
    public array $payload;
}



class Product extends Model
{
    use Fluent;

    #[Relation]
    public Collection $features;
    public Category $category;

    public function features(): HasMany
    {
        return $this->hasMany(Feature::class);
    }

    public function category(): BelongsTo
    {
        return $this->belongsTo(Category::class);
    }
}



class Product extends Model
{
    use Fluent;

    #[HasMany(Feature::class)]
    public Collection $features;
    #[BelongsTo]
    public Category $category;
}