SmsTemplate.php 582 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. class SmsTemplate extends Model
  6. {
  7. use HasFactory;
  8. protected $fillable = [
  9. 'name',
  10. 'content',
  11. 'created_by'
  12. ];
  13. protected $casts = [
  14. 'created_at' => 'datetime',
  15. 'updated_at' => 'datetime',
  16. ];
  17. public function creator()
  18. {
  19. return $this->belongsTo(User::class, 'created_by');
  20. }
  21. public function getCharacterCountAttribute()
  22. {
  23. return strlen($this->content);
  24. }
  25. }