mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 01:57:13 +00:00
* ✨ Set properties from model functions returning an Attribute * ✅ Add test for model Attributes * 🎨 Fix code style * 🔖 Update changelog * ✅ Update test to not require php 8 * 🐛 Fix PHP 7.3 incompatibility * ✅ Update tests to only run when Illuminate Attribute exists
24 lines
548 B
PHP
24 lines
548 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Attributes\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Simple extends Model
|
|
{
|
|
public function name(): Attribute
|
|
{
|
|
return new Attribute(
|
|
function (?string $name): ?string {
|
|
return $name;
|
|
},
|
|
function (?string $name): ?string {
|
|
return $name === null ? null : ucfirst($name);
|
|
}
|
|
);
|
|
}
|
|
}
|