# Cake 3.x Constants in Model

**URL:** <https://discourse.cakephp.org/t/cake-3-x-constants-in-model/6245>\
**Category:** Need Help\
**Created:** [June 11, 2019, 8:12am UTC](https://discourse.cakephp.org/t/cake-3-x-constants-in-model/6245 "2019-06-11T08:12:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cvislam](https://avatars.discourse-cdn.com/v4/letter/c/5f9b8f/32.png) [@cvislam](https://discourse.cakephp.org/u/cvislam)\
**Post date:** [June 11, 2019, 8:12am UTC](https://discourse.cakephp.org/t/cake-3-x-constants-in-model/6245/1 "2019-06-11T08:12:41Z")

</div>

Hi,  
I want to create constants in model.  
I want to access them in table and entity.

Now I create them in Entity and when I need them in Table I call newEntity() to access them.  
I guess there is another - better way.

Example:  
here are the constants decalred int the entity.  
class Banners extends Entity{  
use ThumbTrait;

const IMG\_FOLDER = ‘banners’;  
const UPLOAD\_PATH = IMG\_DIR . self::IMG\_FOLDER;  
const THUMB\_PATH = self::UPLOAD\_PATH . DS . ‘thumb’;  
}

I need the same constants in table  
class BannersTable extends Table{  
public function initialize(array $config){  
parent::initialize($config);

```
$entity = $this->newEntity(); //calling entity to use its constants
$this->addBehavior('UploadFile', [
  'path_thumb' => $entity::THUMB_PATH, //I take constants from entity
  'path_upload' => $entity::UPLOAD_PATH, , //I take constants from entity
  'upload_field' => ['upload_field']
]);

```

}  
}

Is there a better way to use same constants in Entity and Table? - I guess there is

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [June 11, 2019, 3:47pm UTC](https://discourse.cakephp.org/t/cake-3-x-constants-in-model/6245/2 "2019-06-11T15:47:27Z")

</div>

Example code? Without seeing what you’re doing, we would be guessing at what might be good for you.
