How do I solve this laravel layout issue? - php

My error: I am facing this issue quite long time and found one solution in stackoverflow but it doesn't work. I need solution to work with laravel , php 7+ and mysql.
It is showing below error:
ErrorException
Trying to get property 'app_layout' of non-object
Error page consists following code and i tried all solutions in stack overflow but no us. I want to show my layout without any error here.
Error in the script\app\Http\Controllers\MainBaseController.php:26
code on the page is : error line highlighted in BOLD below
use Illuminate\Support\Facades\Schema;
use Froiden\Envato\Traits\AppBoot;
class MainBaseController extends Controller
{
public function __construct()
{
parent::__construct();
// Settings
$this->settings = Setting::first();
$this->year = Common::year();
$this->bootstrapModalRight = true;
$this->bootstrapModalSize = 'md';
**$this->siteLayout = $this->settings->app_layout; // top, sidebar**
$this->forbiddenErrorView = 'errors.403';
$this->showFooter = true;
$this->rtl = $this->settings->rtl;
// Status
$this->statusArray = [
'enabled' => __('app.enabled'),
'disabled' => __('app.disabled')
];
// Setting assets path
$allPaths = Common::getFolderPath();
foreach($allPaths as $allPathKey => $allPath)
{
$this->{$allPathKey} = $allPath;
I am placing error part of the code above , if you need any other parts i will provide

Related

How do I declare a public function in Laravel 8 Base Controller

am getting the following syntax error, unexpected 'public' (T_PUBLIC), expecting end of file when running this code from Microsoft PHP Graph Tutorial.
(https://learn.microsoft.com/en-us/graph/tutorials/php?tutorial-step=1)
public function loadViewData(){
$viewData = [];
// Check for flash errors
if (session('error')) {
$viewData['error'] = session('error');
$viewData['errorDetail'] = session('errorDetail');
}
// Check for logged on user
if (session('userName')) {
$viewData['userName'] = session('userName');
$viewData['userEmail'] = session('userEmail');
$viewData['userTimeZone'] = session('userTimeZone');
}
return $viewData;
}
( I am relatively inexperienced php person, trying to learn laravel and link to Microsoft Graph. There are many tutorials for linking to Microsoft but none of them work as far as I can see, most are out of date. This was my best hope.
Code not working: note line below is one causing problem. If remove 'public;' then no errors are reported in VSCode
i.e. Note in VSCode it reports no errors in the file if public is removed. As soon as you add it back in you get '
As per the the code is correct but you need to check the class of curly brackets properly close or not .
1 ) when you are using the class and no closing curly brackets properly that time it's given error like unexpected 'public' (T_PUBLIC), expecting end of file .
class yourController extends Controller {
public function loadViewData(){
$viewData = [];
// Check for flash errors
if (session('error')) {
$viewData['error'] = session('error');
$viewData['errorDetail'] = session('errorDetail');
}
// Check for logged on user
if (session('userName')) {
$viewData['userName'] = session('userName');
$viewData['userEmail'] = session('userEmail');
$viewData['userTimeZone'] = session('userTimeZone');
}
return $viewData;
}
}

Fatal error: Call to undefined method objectInfo::objectInfo()

I don't find exactly where is my problem. It seems the objectinfo is empty and
I have this error on.
Fatal error: Call to undefined method objectInfo::objectInfo() on this line $bInfo->objectInfo($banner);
My sql request work fine and I verified
There my code where is the problem.
Tk
$parameters = array('expires_date' => '',
'date_scheduled' => '',
'banners_title' => '',
'banners_url' => '',
'banners_group' => '',
'banners_target' => '',
'banners_image' => '',
'banners_html_text' => '',
'expires_impressions' => '',
'banners_title_admin' => ''
);
$bInfo = new objectInfo($parameters);
$bID = HTML::sanitize($_GET['bID']);
$Qbanner = $OSCOM_PDO->prepare('select banners_title,
banners_url,
banners_image,
banners_group,
banners_target,
banners_html_text,
status,
date_format(date_scheduled, "%Y-%m-%d") as date_scheduled,
date_format(expires_date, "%d/%m/%Y") as expires_date,
expires_impressions,
date_status_change ,
customers_group_id,
languages_id,
banners_title_admin
from :table_banners
where banners_id = :banners_id
');
$Qbanner->bindInt(':banners_id', (int)$bID);
$Qbanner->execute();
$banner = $Qbanner->fetch();
$bInfo->objectInfo($banner); // pb is here
As par i know this Fatal error occur due to the updated version of the php.
Earlier, we are able to autoload the class property by using the same function name of the class name.
In Earlier varsion of PHP, we can able to call or define the Same Function name of the class name.
But new the Latest version of php we can not do that. if we use the same function name of the class name and if we call this function name then it give us the fatal error like you received in this post.
So the solution is as follow.
Go to the class objectInfo ( or whatever you have )
your class file is currently have
class objectInfo {
function objectInfo($object_array) {
your function code here.....
}
}
Change the function name from objectInfo to __construct. so the entire class is looking like as below
class objectInfo {
function __construct($object_array) {
your function code here.....
}
}
currently you call the function like
$bInfo = new objectInfo($parameters);
$bInfo->objectInfo($banner);
so change above code as below.
$bInfo = new objectInfo($parameters);
$bInfo->__construct($banner);
so finally hope that your error will be solved.
The line $bInfo = new objectInfo($parameters); created a new instance of the objectInfo class. Then you attempt to call the method objectInfo() of this class. The error message just tells you that this class has no such method. Can you show the source code for the class objectInfo?

blank page after changed link - smarty

I wanted to help a friend on his website and he told me to change a link. he use smarty and the website is online
so i change this
<li class="first">Le réseau</li>
to absolute path.
Now, i have this error
Fatal error: Call to undefined function reecrire_url() in /home/deflandrgb/www/includes/smarty/sysplugins/smarty_internal_filter_handler.php on line 60
But I have not changed anything except link.
why I have this error?
Thanks
ps: I handed the old link but I still have the same error
EDIT : i find this function in Site_Smarty.class.php
class Site_Smarty extends Smarty{
public function Site_Smarty(){
parent::__construct();
//$this->caching = true;
//$this->compile_check = true;
$this->template_dir = root.'templates/';
$this->compile_dir = root.'templates_c/';
$this->config_dir = root.'includes/smarty/';
$this->cache_dir = root.'cache/';
//$this->debugging = true;
$this->registerFilter('pre','reecrire_url');
$this->assign('app_name', 'Guest Book');
$this->assign('path', path);
}
}
Seems you missed to define the callback function "reecrire_url"
See docs:
http://www.smarty.net/docs/en/api.register.filter.tpl

Fatal Error On Zend Project Live On Server Random

I have a Zend2 project running on my localhost with no problems. The app runs perfect. I Uploaded it to my server and now it gets a fatal error but not every time.
Sometimes it says this,
Fatal error: Class name must be a valid object or a string in /home/public_html/vendor/zendframework/zend-stdlib/src/ArrayObject.php on line 230
public function getIterator()
{
$class = $this->iteratorClass;
return new $class($this->storage); // line 230
}
And sometimes it says this,
File
/vendor/zendframework/zend-stdlib/src/ArrayObject.php:184
Message:
Passed variable is not an array or object, using empty array instead
Never both and sometimes it loads perfectly with no problems. The file it references is in the vendor path this is the link,
public function exchangeArray($data)
{
if (!is_array($data) && !is_object($data)) {
throw new Exception\InvalidArgumentException('Passed variable is not an array or object, using empty array instead');
} // Line 184
if (is_object($data) && ($data instanceof self || $data instanceof \ArrayObject)) {
$data = $data->getArrayCopy();
}
if (!is_array($data)) {
$data = (array) $data;
}
$storage = $this->storage;
$this->storage = $data;
return $storage;
}
Any ideas why this would happen on a live server with a zend site but not on a localhost?
I found this post on github which I think it related to ZFCUser
Git Hub Post
Someone in the comments says this,
This issue is caused by the layout.phtml when there is an error. The layout needs to render but it doesn't have $this->url
I have no clue what he is talking about. Is anyone able to shoot me in the right direction?

Undefined variable Error Laravel only on Live Server

I am working on a custom Laravel Project.
I am getting following error:
Undefined variable: count_pandding (View: /domains/web4/html/manager/app/views/admin/home.blade.php)
but strange thing is this error does not show in localhost and works perfectly only in life server.
I have tried passing variables in 2 ways:
public function home()
{
$count_pandding = \Postjob::where('approve',0)->get()->count();
$count_disapprove = \Postjob::where('approve',2)->get()->count();
$count_approve = \Postjob::where('approve',1)->get()->count();
$count_expire = \Postjob::where('approve',3)->get()->count();
return View::make('admin.home', compact('count_pandding','count_disapprove','count_approve','count_expire'));
}
and 2nd way
public function home()
{
$data['count_pandding'] = \Postjob::where('approve',0)->get()->count();
$data['count_disapprove'] = \Postjob::where('approve',2)->get()->count();
$data['count_approve'] = \Postjob::where('approve',1)->get()->count();
$data['count_expire'] = \Postjob::where('approve',3)->get()->count();
return View::make('admin.home',$data);
}
None of it works in Life Server! But works perfectly in Localhost.
Please review Larvel Response
The second parameter of make is an array with key value bindings. I find it strange that this is working on your local machine.
Try
return View::make('admin.home', [
'count_pandding' => $count_pandding,
...
]);
Or
return View::make('admin.home')->withCountPannding($count_pannding);
//this becomes $countPannding in your view
Update:
return View::make('admin.home')->with($keyValueArray);
//should also translate into $key inside the view.

Categories