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);
Related
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.
Getting error
"message": "Undefined property: App\Http\Controllers\Api\ApiUserXYzController::$response"
return $this->response->collection($user_list, new ProjectTransformer())->setStatusCode(200);
I"m tring to transform the data but i'm getting $response is not defined. please guide
You forgot to include the helper trait that the docs tell you to use if you want the response builder at the property response on the controller.
Dingo Wiki - Responses - Response Builder
use Dingo\Api\Routing\Helpers;
class SomeController ....
{
use Helpers;
...
}
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}
can somebody tell me what's wrong with this code? This is located in my controller. I have an error message "Message: Call to undefined method CI_Input::manufacturer()"
public function edit_manufacturer(){
$this->load->helper("security");
$id = $this->uri->segment(3);
if($this->input->manufacturer('submit')){
$manufacturer_name = $this->security->xss_clean($this->input->manufacturer('manufacturer_name'));
$this->asset_model->edit_manufacturer($manufacturer_id, $manufacturer_name);
}
}
input is a reserved class from CodeIgniter and the methods are the following
$this->input->post();
$this->input->get();
$this->input->cookie();
$this->input->server();
therefore, manufacturer method doesn't exist unless you modified this class and created the method.
Maybe what you want to do is:
$this->input->post('manufacturer');
or
$this->input->post('submit');
For more information visit Input Class Documentation
I have a class in application/library folder - filename = person_struc.php and the code is following..
class Person_struc {
var $person_id;
var $person_name;
public function set_info($person_id, $person_name) {
$this->person_id = $person_id;
$this->person_first_name = $person_name;
}
}
I have a view (person_list.php) and want to load the class by as follows -
$this->load->library('person_struc');
$this->person_struc->set_info(1,"xxx");
I have controller (person) and model (person_model). But it is generating error..
A PHP Error was encountered
Severity: Notice
Message: Undefined property: CI_Loader::$person_struc
Filename: person/person_list.php
Fatal error: Call to a member function set_info() on a non-object in
I tried to solve the problem but failed. Do you have any solution please...
Initial letter of your file name must be capital. In your case it would be filename = Person_struc.php instead of filename = person_struc.php
Try like
class Person_struc extends CI_Controller
your class must be locate in library.
your class name and file name are same.
and your person_list controller must be extends CI_CONTROLLER