mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Merge pull request #17044 from MadBox-99/patch-2
Update casts syntax in docs
This commit is contained in:
@@ -10,9 +10,15 @@ class Post extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $casts = [
|
||||
'is_featured' => 'boolean',
|
||||
];
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'is_featured' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function author(): BelongsTo
|
||||
{
|
||||
|
||||
@@ -37,14 +37,15 @@ class User extends Authenticatable implements FilamentUser
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'colleagues' => 'array',
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'colleagues' => 'array',
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function canAccessPanel(Panel $panel): bool
|
||||
{
|
||||
|
||||
@@ -60,12 +60,15 @@ class User extends Authenticatable implements FilamentUser, MustVerifyEmail
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
// ...
|
||||
'app_authentication_secret' => 'encrypted',
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
// ...
|
||||
'app_authentication_secret' => 'encrypted',
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
@@ -165,12 +168,15 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
// ...
|
||||
'app_authentication_recovery_codes' => 'encrypted:array',
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
// ...
|
||||
'app_authentication_recovery_codes' => 'encrypted:array',
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
@@ -337,14 +343,16 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
|
||||
class User extends Authenticatable implements FilamentUser, MustVerifyEmail
|
||||
{
|
||||
// ...
|
||||
/**
|
||||
* @var array<string, string>
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
// ...
|
||||
'has_email_authentication' => 'boolean',
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
// ...
|
||||
'has_email_authentication' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
@@ -27,12 +27,18 @@ class Export extends Model
|
||||
{
|
||||
use Prunable;
|
||||
|
||||
protected $casts = [
|
||||
'completed_at' => 'timestamp',
|
||||
'processed_rows' => 'integer',
|
||||
'total_rows' => 'integer',
|
||||
'successful_rows' => 'integer',
|
||||
];
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'completed_at' => 'timestamp',
|
||||
'processed_rows' => 'integer',
|
||||
'total_rows' => 'integer',
|
||||
'successful_rows' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
@@ -16,9 +16,15 @@ class FailedImportRow extends Model
|
||||
{
|
||||
use Prunable;
|
||||
|
||||
protected $casts = [
|
||||
'data' => 'array',
|
||||
];
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'data' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
@@ -28,12 +28,18 @@ class Import extends Model
|
||||
{
|
||||
use Prunable;
|
||||
|
||||
protected $casts = [
|
||||
'completed_at' => 'timestamp',
|
||||
'processed_rows' => 'integer',
|
||||
'total_rows' => 'integer',
|
||||
'successful_rows' => 'integer',
|
||||
];
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'completed_at' => 'timestamp',
|
||||
'processed_rows' => 'integer',
|
||||
'total_rows' => 'integer',
|
||||
'successful_rows' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
@@ -219,9 +219,15 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class App extends Model
|
||||
{
|
||||
protected $casts = [
|
||||
'technologies' => 'array',
|
||||
];
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'technologies' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
@@ -23,9 +23,15 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class User extends Model
|
||||
{
|
||||
protected $casts = [
|
||||
'is_admin' => 'boolean',
|
||||
];
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'is_admin' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
@@ -23,9 +23,15 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class User extends Model
|
||||
{
|
||||
protected $casts = [
|
||||
'is_admin' => 'boolean',
|
||||
];
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'is_admin' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
@@ -32,9 +32,15 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class App extends Model
|
||||
{
|
||||
protected $casts = [
|
||||
'technologies' => 'array',
|
||||
];
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'technologies' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
@@ -75,9 +75,15 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Message extends Model
|
||||
{
|
||||
protected $casts = [
|
||||
'attachments' => 'array',
|
||||
];
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'attachments' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
@@ -37,9 +37,15 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Post extends Model
|
||||
{
|
||||
protected $casts = [
|
||||
'content' => 'array',
|
||||
];
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'content' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
@@ -26,9 +26,15 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Post extends Model
|
||||
{
|
||||
protected $casts = [
|
||||
'tags' => 'array',
|
||||
];
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'tags' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
@@ -23,9 +23,15 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Post extends Model
|
||||
{
|
||||
protected $casts = [
|
||||
'meta' => 'array',
|
||||
];
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'meta' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
@@ -196,9 +196,15 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class App extends Model
|
||||
{
|
||||
protected $casts = [
|
||||
'technologies' => 'array',
|
||||
];
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'technologies' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
@@ -139,9 +139,15 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Post extends Model
|
||||
{
|
||||
protected $casts = [
|
||||
'slider' => 'array',
|
||||
];
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'slider' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
@@ -33,9 +33,15 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Post extends Model
|
||||
{
|
||||
protected $casts = [
|
||||
'meta' => 'array',
|
||||
];
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'meta' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
@@ -14,13 +14,19 @@ class Post extends Model
|
||||
use HasFactory;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $casts = [
|
||||
'string_backed_enum' => StringBackedEnum::class,
|
||||
'is_published' => 'boolean',
|
||||
'tags' => 'array',
|
||||
'json' => 'array',
|
||||
'json_array_of_objects' => 'array',
|
||||
];
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'string_backed_enum' => StringBackedEnum::class,
|
||||
'is_published' => 'boolean',
|
||||
'tags' => 'array',
|
||||
'json' => 'array',
|
||||
'json_array_of_objects' => 'array',
|
||||
];
|
||||
}
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
|
||||
@@ -33,15 +33,18 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'json' => 'array',
|
||||
'email_verified_at' => 'datetime',
|
||||
'app_authentication_secret' => 'encrypted',
|
||||
'app_authentication_recovery_codes' => 'encrypted:array',
|
||||
'has_email_authentication' => 'boolean',
|
||||
];
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'json' => 'array',
|
||||
'email_verified_at' => 'datetime',
|
||||
'app_authentication_secret' => 'encrypted',
|
||||
'app_authentication_recovery_codes' => 'encrypted:array',
|
||||
'has_email_authentication' => 'boolean',
|
||||
];
|
||||
}
|
||||
|
||||
public function canAccessPanel(Panel $panel): bool
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user