Smarty trying to echo the config item its not working - smarty

Smarty codeigniter3 print config item not working. I am trying to do the following thing
{$this->session->userdata('userid')}
{$this->config->item(base_url)}
I am getting this error,
A PHP Error was encountered
Severity: Error
Message: Call to a member function item() on a non-object

You need to write a array as data in controller like this
public function myFunction()
{
$data['base']=$this->config->item('base_url');
$data['userid']=$this->session->userdata('userid');
$this->smarty->view('yourview.tpl',$data);
}
then in your smarty page write this
{$userid}{$base}

Related

Laravel Spotify gives error - even when following Github

So I'm using this package: https://github.com/aerni/laravel-spotify for a project, and I've followed the "Usage-steps", but I keep getting this error:
Non-static method Aerni\Spotify\Spotify::searchTracks() should not be called statically
when I do it the way the package says.
This is my code:
public function index()
{
$variable = Spotify::searchTracks('Wish You Were Here')->get();
dd($variable);
return view('pages.index');
}
with
use Aerni\Spotify\Spotify;
on top of the file. Because of the error I tried this:
(new Spotify)->searchTracks('Wish You Were Here')->get();
but I get this error:
Too few arguments to function Aerni\Spotify\Spotify::__construct(), 0 passed in C:\ProjectDirectory\hetplatenhuis-newversion\app\Http\Controllers\Pages\IndexController.php on line 13 and exactly 1 expected
Is there anyone who has experience with this package?

Error Undefined error:addition in laravel

I am creating some code using laravel in controller and i want send array from controller to blade file i face problem 1/1) ErrorException
Undefined variable: addition It runs but now face this error
$get_details=DB::select('SELECT deliver_date,GROUP_CONCAT(orders_qty) as orders_qty FROM `orders` WHERE order_status=? and deliver_date between ? AND ? GROUP BY deliver_date',[6,'2019-02-01','2020-02-05']);
foreach($get_details as $date_wise_details)
{
$array=explode(',',$date_wise_details->orders_qty);
$addition[]=array_sum($array);
}
return view('dashboard',['get_data'=>$get_details])->with('addition',$addition);
You need to define addition array to resolve this issue
$addition = []; // define your array here
foreach($get_details as $date_wise_details)
{
$array=explode(',',$date_wise_details->orders_qty);
$addition[]=array_sum($array);
}

Having trouble with Model Bind - Laravel Breadcrumbs

Having trouble with Model Bind on davejamesmiller/laravel-breadcrumbs.
I'll try to be brief, but if you need more data just ask =D
This is my controller/action signature:
public function edit(Request $request, Vertical $vertical, UserMacro $macro)
And this is my BC for the corresponding route:
Breadcrumbs::register('macro-edit', function (Generator $breadcrumbs, $vertical, $macro) {
$breadcrumbs->parent('macro-index');
$breadcrumbs->push($macro->name, route('macro-edit', [$vertical->_id, $macro]));
});
I'm getting the string ID on $vertical and $macro, breaking on $macro->name. If I add Hints as the action have I get aType error.
Trying to get property of non-object (View: /.../resources/views/layouts/app.blade.php) (View: /.../resources/views/layouts/app.blade.php)
Type error: Argument 2 passed to DaveJamesMiller\Breadcrumbs\BreadcrumbsServiceProvider::{closure}() must be an instance of App\Vertical, string given, called in /.../vendor/davejamesmiller/laravel-breadcrumbs/src/BreadcrumbsGenerator.php on line 68 (View: /.../resources/views/layouts/app.blade.php) (View: /.../resources/views/layouts/app.blade.php)
I didn't analyze core code of library, so i don't know why controllers work, but breadcrumbs don't. Recipe to working model binding is use proper route naming convention.
Breadcrumbs::for('messages.show', function($trail, \App\Models\MassMessage $massMessage) {
$trail->parent('Index');
$trail->push('Show', route('messages.show', $massMessage));
});
Route::get('messages/{massMessage}', 'MessageController#show')->name('messages.show');
// error (controllers are fine)
Route::get('mass-mmessages/{massMessage}', 'MessageController#show')->name('messages.show');
// works both
The same problem is with resource route.
edit:
I was wrong. Controller also doesn't work. It not raise error but it pass empty Eloquent object. In my case i needed to change $massMessage variable's name into $message in both places and works fine, now.

Code Igniter Model unable to use url->segment

this error arises when I try to get url segement
Severity: Notice
Message: Undefined property: Site::$url
Filename: core/Model.php
This is the code of model class
Modeland this is function in controller
Controller
View
Replace url with uri
$this->uri->segment(3);

Fatal error: Call to a member function setTitle() on a non-object

When I try to placing an order, while selecting the shipping method an error is getting saying
Fatal error: Call to a member function setTitle() on a non-object in /home/exclus31/public_html/../../../app/code/core/Mage/Customer/Block/Form/Login.php on line 40
But there is no problem for placing the order and got the confirmation message for the particular order.
Any one know why this error is shown and a solution for this?
I had this error as well. It was because I was calling getLayout() in my IndexAction() before I had loaded the layout. Just call loadLayout() first, like so:
public function IndexAction() {
$this->loadLayout(); // do this first
$this->getLayout()->getBlock('head')->setTitle($this->__('My Title')); // then this works
$this->renderLayout(); // render as usual
}
I hope this helps

Resources