bobmulder on master
Use 'fields' from CreatedBy or … (compare)
martonmiklos on master
Fix null pointer exception in W… (compare)
@termlimit Gitter works with markdown. To create code-blocks you need to add 3 quotes who are above your Tab-button and before the 1-button. This quotes: ->`<- (haha, don't know how to explain :P). So add 3 quotes above your code, and after your code and your code will be shown in a block.
About your issue; I've always learned that Models should not handle ownership stuff. So in fact the model should not even know about roles and ownerships and stuff. And to be honest I agree with that. The GlobalAuth-behavior is just a thing to hack around it if you need it. So in your case you could create a custom finder as you mentioned. Your query-call would look like:
$this->Accounts()->find()->find('ownership', $userId);
I hope this will help you. Because this stuff isn't releated anymore to the utils-library I suggest you should contact me privately via Gitter if you have questions ;)
Have fun coding ;)
Hi there,
I'm starting to wonder what I'm doing wrong and I think I'm starting to lose my hair (still fairly new to CakePHP)
I'm trying to implement the uploader and have followed all the documentation (at least I think I have) and it's failing to put the file where I tell it to but it IS updating the MYSQL Table with the required filename (although I would like it to put the full path. i.e. 'webroot/uploads/<username>/20160707.jpeg')
{{Code Follows}}
View Code (profile.ctp)<?= $this->Form->create($user, array('role' => 'form')) ?>
<div class="box-body">
<?php//Profile Avatar Box
echo $this->Html->image('avatar5.png', array('class' => 'img-thumbnail', 'alt' => 'User Image'));//Upload new Avatar
echo $this->Form->create($user, ['type' => 'file']);echo $this->Form->input('avatar', ['type' => 'file']);
echo $this->Form->input('username');echo $this->Form->input('password');
echo $this->Form->input('name');echo $this->Form->input('surname');
echo $this->Form->input('email');echo $this->Form->input('mobile_number');
?></div>
<!-- /.box-body --><div class="box-footer">
<?= $this->Form->button(('Save')) ?></div>
<?= $this->Form->end() ?>
Users Table$this->addBehavior('Utils.Uploadable', [
'avatar' => ['field' => 'id',
'path' => '{ROOT}{DS}webroot{DS}uploads{DS}','fileName' => '{field}.{extension}'
],
` ]);
//if (!is_dir($this->_getPath($entity, $field, ['root' => false, 'file' => false]))) {
if(!file_exists($this->_getPath($entity, $field, ['root' => false, 'file' => false]))){
$this->_mkdir($this->_getPath($entity, $field, ['root' => true, 'file' => false]), 0777, true);
}
mkdir
should create the dir right?
$this->addBehavior('Utils.Uploadable', [
'avatar' => [
'path' => '{ROOT}{DS}{WEBROOT}{DS}files{DS}{model}{DS}avatar{DS}{field}{DS}',
'fields' => [
'fileName' => 'avatar'
]
]
]);
But as this is not working, I would suggest you check it as it seems to be a bug to me. The docs say: fileName - this column contains the name of the file. For example: myFile.png. -> but the whole path is saved.