i'm using laravel 5.5.* and install this https://github.com/artesaos/defender package for roles and permission, all things working fine but when i try to get permission
$permissions = array_map(function ($permission) {
return $permission['name'];
}, $user->getAllPermissions()->toArray());
getting blow error:
"Symfony\Component\Debug\Exception\FatalThrowableError" file : H:\xampp\htdocs\LaraVueAdmin\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php"
line: 147 message : "Type error: Argument 1 passed to Illuminate\Database\Eloquent\Model::__construct() must be of the type array, object given, called in H:\xampp\htdocs\LaraVueAdmin\vendor\artesaos\defender\src\Defender\Traits\Models\Permission.php on line 75"
This solution of Muzafar Ali, worked for me:
I found out the solution by replacing github.com/artesaos/defender/blob/master/src/Defender/Traits/…
with
return PermissionUserPivot::fromRawAttributes($parent, $attributes,
$table, $exists, $using);
Related
I'm currently new to Laravel and trying to learn it. I worked now many hours with it and tried to install and use now the Laravel ACL from https://github.com/mateusjunges/laravel-acl
But I keep getting errors with it.
My Steps:
Installed
tried php artisan migrate -> not worked -> Nothing to migrate.
tried it manually -> copying the migration files from vendor>mateusjunges>laravel-acl>database>migrations> into ..database>migrations
Again php artisan migrate -> worked
tried php artisan permission:create testperm testperm "test"-> error
Error:
Call to undefined method Illuminate\Foundation\Application::where()
at testproject\vendor\mateusjunges\laravel-acl\src\Console\Commands\CreatePermission.php:43
39▕ public function handle()
40▕ {
41▕ $permissionModel = app(config('acl.models.permission'));
42▕
➜ 43▕ $permission = $permissionModel->where('slug', $this->argument('slug'))
44▕ ->orWhere('name', $this->argument('name'))
45▕ ->first();
46▕
47▕ if (! is_null($permission)) {
1 testproject\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:36
Junges\ACL\Console\Commands\CreatePermission::handle()
2 testproject\vendor\laravel\framework\src\Illuminate\Container\Util.php:40
Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
tried php artisan user:permissions 1 -> next error
Error:
Call to undefined method Illuminate\Foundation\Application::find()
at testproject\vendor\mateusjunges\laravel-acl\src\Console\Commands\UserPermissions.php:44
40▕ $userParameter = $this->argument('user');
41▕ $userModel = app(config('acl.models.user'));
42▕
43▕ if (is_numeric($userParameter)) {
➜ 44▕ $user = $userModel->find((int) $userParameter);
45▕ } elseif (is_string($userParameter)) {
46▕ $table = config('acl.tables.users');
47▕ $columns = $this->verifyColumns($table);
48▕
1 testproject\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:36
Junges\ACL\Console\Commands\UserPermissions::handle()
2 testproject\vendor\laravel\framework\src\Illuminate\Container\Util.php:40
Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
I dont know what I did wrong, the installation was successful...
You have to see the documentation of the package, it is going always to be hard if you try by your own...
This is the documentation, and it clearly says: To install run php artisan acl:install, and then you have one more that will add all the needed files you are missing (that's why the error) php artisan vendor:publish --provider="Junges\ACL\Providers\ACLServiceProvider" --tag="acl-migrations"...
Read the documentation please...
Using phpGACL with db_type = "mysqli" in gacl.ini.php still got below error,
"Fatal error: Uncaught Error: Call to undefined function
mysql_pconnect()"
when create gacl class but phpGACL admin works fine.
<?php
include ("gacl.class.php");
$gacl = new gacl();
?>
I expect it should work fine as phpGACL admin do.
Finally, I make a small patch to make it work.
Change the code in gacl.class.php line 110.
function gacl($options = NULL) {
to
function __construct($options = NULL)
When create a gacl object, it must passing the db_type parameter instead of rely on gacl.ini.php setting.
$gacl = new gacl(array("db_type"=>"mysqli"));
Modify gacl.class.php line 455, remove & sign
$row =& $rs->FetchRow();
to
$row = $rs->FetchRow();
Modify profiler.inc line 37, 180
function Profiler( $output_enabled=false, $trace_enabled=false);
$tmp=split(" ",microtime());
to
function __construct( $output_enabled=false, $trace_enabled=false)
$tmp=explode(" ",microtime());
In order to make build in GACL admin work perfectly, also need to update ADODB, Smarty2 to latest version 2.6.31 (Smarty 3 is not compatible). acl_debug.tpl line 42 add # sign to count function.
{if #count($acls) gt 0}
# sign to by pass count uncountable error as a quick fix. Need further study the code for long term solution.
Fix a bug in group_admin.php
$formatted_groups = $gacl_api->format_groups($gacl_api->sort_groups($group_type), HTML);
to
$formatted_groups = $gacl_api->format_groups($gacl_api->sort_groups($group_type), 'HTML');
My code follows what is indicated here
https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/user_assignlicense
$datos=array("addLicenses"=>array(array("skuId"=>$sku)));
$this->graph->setApiVersion("beta");
$this->crear("users/$id_user/assignLicense", $datos);
public function crear($objeto, $datos){
$r = $this->graph->createRequest("POST", "/$objeto")
->attachBody($datos)
->execute();
}
Error
Type: GuzzleHttp\Exception\ClientException
Message: Client error: `POST
https://graph.microsoft.com/beta/users/USER_ID/assignLicense` resulted in a `400 Bad Request` response: {
"error": { "code": "Request_BadRequest", "message": "One or more parameters
of the function import 'assig (truncated...)
Filename: /var/www/html/ischooldesarrollo/application/libraries/msgraph-sdk-
php/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php
Line Number: 111
What is my mistake?
Couple of things:
Not that it's the problem, but why aren't you using v1.0?
The payload/body for the method requires 2 array parameters - addLicenses and removeLicenses. I don't see the second one. If you are just adding licenses, set removeLicenses to an empty array.
The addLicenses array is an array of [disabledPlans and skuId], with disabledPlans itself being an array. If you don't want to disable any plans, just set this to an empty array.
Hope this helps,
SOLVED
I solved this issue with Jonathan Hussey help
I changed this line:
$mModel->getCollection()->load($mId)->getData();
for this:
$mModel->getCollection()->addFieldToFilter('met_id',$Id)->getSelect();
Problem
I created custom module which added tab to admin product page with additional text field.
When I try save this product I get this error:
a:5:{i:0;s:140:"Cannot send headers; headers already sent in /home/nano/domains/mydomain/public_html/gw/lib/Varien/Data/Collection/Db.php, line 693";i:1;s:1630:"#0 /home/nano/domains/mydomain/public_html/gw/lib/Zend/Controller/Response/Abstract.php(148): Zend_Controller_Response_Abstract->canSendHeaders(true)...
I saw that this error created in Observer.php:
$mId = $collection['m_id'];
$mModel->getCollection()->load($mId)->getData(); <-- this line give an error
$data['met_id'] = $mId;
$data['product_id'] = $product->getId();
$data['metf1'] = $this->_getRequest()->getPost('f1');
$mModel->setData($data);
$mModel->save();
Do you have any ideas how fix this ?
EDIT
content of admin template tab file:
<?php
$product = Mage::registry('current_product');
$mItem = Mage::getModel('mmodel/mmodel')->getCollection()->
addFilter('product_id',$product->getId())->getFirstItem();
echo '<div class="input-field">
<label for="f1">File</label>
<input type="text" class="input-text" name="f1" id="f1" value='.$mItem['f1'].' />
</div>';
Debug backtrace after line $mModel->getCollection()->load($mId)->getData(); from Observer.php
SELECT `main_table`.* FROM `mmodel` AS `main_table`
Debug Backtrace:
File Line Function
/home/nano/domains/mydomain/public_html/gw/app/code/local/GW/MModel/Model/Observer.php 42 printDebugBacktrace
/home/nano/domains/mydomain/public_html/gw/app/code/core/Mage/Core/Model/App.php 1338 saveProductTabData
/home/nano/domains/mydomain/public_html/gw/app/code/core/Mage/Core/Model/App.php 1317 _callObserverMethod
/home/nano/domains/mydomain/public_html/gw/app/Mage.php 468 dispatchEvent
/home/nano/domains/mydomain/public_html/gw/app/code/core/Mage/Core/Model/Abstract.php 466 dispatchEvent
/home/nano/domains/mydomain/public_html/gw/app/code/core/Mage/Catalog/Model/Product.php 548 _afterSave
/home/nano/domains/mydomain/public_html/gw/app/code/core/Mage/Core/Model/Abstract.php 319 _afterSave
/home/nano/domains/mydomain/public_html/gw/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php 714 save
/home/nano/domains/mydomain/public_html/gw/app/code/core/Mage/Core/Controller/Varien/Action.php 419 saveAction
/home/nano/domains/mydomain/public_html/gw/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php 250 dispatch
/home/nano/domains/mydomain/public_html/gw/app/code/core/Mage/Core/Controller/Varien/Front.php 176 match
/home/nano/domains/mydomain/public_html/gw/app/code/core/Mage/Core/Model/App.php 354 dispatch
/home/nano/domains/mydomain/public_html/gw/app/Mage.php 704 run
/home/nano/domains/mydomain/public_html/gw/index.php 87 run
When working with collections you should only pass arguments to ->load() if you want the SQL for that collection to be logged or output. If you don't want the collection to return all items you can pull the select object from the collection with ->getSelect() and filter with standard Zend methods this way.
If you trace back your collection command you will see because you pass an argument it echo's out the collection SQL.
$mModel->getCollection()->load($mId)->getData();
Have a look at lib/Varien/Data/Collection/Db.php as per the error message and find the load() method. You will see that it accepts two aguments, $printQuery and $logQuery, you have passed an argument to $printQuery. A few lines down in the method you see:
$this->printLogQuery($printQuery, $logQuery);
Looking at the printLogQuery() method you will see that anything passed as the $printQuery argument which evaluates to true triggers the echo on line 693 as per the error message:
echo is_null($sql) ? $this->getSelect()->__toString() : $sql;
This is what is sending headers in your case. Remove the argument from ->load() or pass false and it should fix your problem.
Helllo,
Recently I upgraded to 6.2 GA from 6.1.4 via the upgrade patch.
Even since then I'm unable to create anything that has direct relation with Date & Time, namely, Call Logs, Meetings and Tasks.
When I do the same using a subpanel, the entry simply vanishes and is NEVER created.
When I try from one of the respective modules under Activities, I get a HTTP 500 error upon submission.
The Apache error log reveals the following:
PHP Catchable fatal error: Argument 1 passed to TimeDate::_getUserTZ() must be
an instance of User, boolean given, called in /home/crm/include/TimeDate.php on
line 849 and defined in /home/crm/include/TimeDate.php on line 259, referer:
http://mysite/index.php?module=Leads&offset=1&stamp=1307694072083825200&return_module=Leads&action=DetailView&record=xxxxxxxxxxxx
Unfortunately, this has happened to a production server and I noticed this problem only too late.
How can I fix this? Seeking your help urgently.
Thanks,
m^e
UPDATE 1
I've managed to apply a temporary patch to this and got it working...
Line 849 of TimeDate.php is part of a function that looks like:
function to_display_date_time($date, $meridiem = true, $convert_tz = true, $user = null)
{
return $this->_convert($date,
self::DB_DATETIME_FORMAT, self::$gmtTimezone, $this->get_date_time_format($user),
$convert_tz ? $this->_getUserTZ($user) : self::$gmtTimezone, true);
}
This function is in turn calling another one _getUserTZ() to which it is supposed to pass a variable of the type User. Instead it is passing null.
I used a snippet to check for empty $user and assign a value to it if needed. The code is part of another function named _getUser() found in this same file....
protected function _getUser(User $user = null)
{
if (empty($user)) {
$user = $this->user;
}
if (empty($user)) {
$user = $GLOBALS['current_user'];
}
return $user;
}
I borrowed the code from this function and pasted it inside to_display_date_time(), making it look like:
function to_display_date_time($date, $meridiem = true, $convert_tz = true, $user = null)
{
if (empty($user)) {
$user = $this->user;
}
if (empty($user)) {
$user = $GLOBALS['current_user'];
}
return $this->_convert($date,
self::DB_DATETIME_FORMAT, self::$gmtTimezone, $this->get_date_time_format($user),
$convert_tz ? $this->_getUserTZ($user) : self::$gmtTimezone, true);
}
Now Calls / Meetings are working again.. but I still wonder what's the actual fix to this issue. My way should prove to be a quick fix for anyone who needs to rectify this in a hurry.
If anyone can get to the root of the problem and a more elegant fix, I'm willing to offer a bounty.
Cheers,
m^e