Hi everyone,
hope someone can help me out with this question:
OctoberCms offers mutators (https://octobercms.com/docs/database/mutators) to manipulate DB field content view very conveniently. Like doing so:
<?php namespace Acme\Blog\Models;
use Model;
class User extends Model
{
public function getFirstNameAttribute($value)
{
return ucfirst($value);
}
}
But is there a way to return different values depending on weather this is called a) by a backend list view, b) a backend form view, c) a frontend form (using the php code section)?
something like this:
...
public function getFirstNameAttribute($value)
{
// if backend list view
return ucfirst($value);
// if backend form view
return strtolower($value);
// if frontend view
return strtoupper($value);
}
...
Last updated