I want to save $id_lowongan,$id_kategori
but i get error
Type: ArgumentCountError
Message: Too few arguments to function Lowongan::lamar(), 1 passed in /home/denr6524/public_html/rekrutmen/system/core/CodeIgniter.php on line 532 and exactly 2 expected
Filename: /home/denr6524/public_html/rekrutmen/application/controllers/pencari/Lowongan.php
Line Number: 45
Backtrace:
File: /home/denr6524/public_html/rekrutmen/index.php
Line: 315
Function: require_once
this my controller
public function lamar($id_lowongan,$id_kategori) {
$id_user = $this->session->userdata('id_user');
$profile = $this->user_model->detail($id_user);
$lowongan = $this->lowongan_model->detail($id_lowongan);
$kategori = $this->kategori_model->detail($id_kategori);
$lowongan = $this->lowongan_model->status_lamaran($id_user);
$data = array(
'id_lowongan' => $id_lowongan,
'id_user' => $id_user,
'id_kategori' => $id_kategori,
'status_lamaran' => "Lamaran Sedang Diproses"
);
$this->lowongan_model->lamaran($data);
$this->session->set_flashdata('Sukses', 'Lamaran Berhasil dikirim');
redirect(base_url('pencari/lowongan'),'refresh');
}
Too few arguments to function Lowongan::lamar()-> it seems you are passing $id_lowongan not $id_kategori, if you are passing $id_kategori(check value).Print these two values before calling the function!
Related
I'm trying to the the following piece of code:
public function remember(string $key, \Closure $callback, int $ttl = null): mixed
{
return \Cache::remember($key, $ttl, $callback);
}
with:
public function testRememberWhenTimeoutIsSet(): void
{
\Cache::shouldReceive('remember')
->once()
->with(\Mockery::on(function ($key, $ttl, $callback) {
return $key === 'key' && $ttl === 123 && is_callable($callback);
}))
->andReturn('any-thing');
$this->assertEquals(
'any-thing',
$this->service->remember('key', function () {}, 123)
);
}
But it keeps giving me the following error:
Mockery\Exception\NoMatchingExpectationException : No matching handler
found for Mockery_2_Illuminate_Cache_CacheManager::remember('key',
123, object(Closure)). Either the method was unexpected or its
arguments matched no expected argument list for this method
Objects: ( array ( 'Closure' => array (
'class' => 'Closure',
'identity' => '#3e713b47f2e6096de32a4437ee0381ff',
'properties' =>
array (
), ), ))
The error goes away if to completely remove with block. Any ideas?
You can consider the code below to work well:
Cache::shouldReceive('remember')
->once()
->with('key', 123, \Closure::class)
->andReturn('any-thing')
;
with method in your case doesn't need a CLOSURE matcher but only a list of expected arguments.
I have a query that I am not able to pass to the view.
$dias_usados = calendario::where('id_funcionario', '=', $userid)
->groupBy('id_funcionario')
->sum('contaferias');
dd outputs the correct expected value.
I tried to pass to the View as follows:
return view(
'ausencia',
compact('tabela'),
['itens' => $ferias],
['dias_usados' => $dias_usados]
);
I'm having problems with the last one dias_usados. The first two work normally.
<h3>{{$dias_usados}}</h3>
Causes the following error:
Undefined variable: "dias_usados"
I also leave the path I have on the route, but I don't see anything wrong
Route::get('Ausencia', [AusenciaController::class, 'index'])->name('ausencia.index');
This is the the definition of the view helper
function view($view = null, $data = [], $mergeData = []) { }
You are misusing the function by giving it three separate arrays expecting it to get them as $data.
Fixes
return view('ausencia', [
'tabela' => $tabela,
'itens' => $ferias,
'dias_usados' => $dias_usados,
]);
return view('ausencia')
->with(compact('tabela'))
->with(['itens' => $ferias])
->with(['dias_usados' => $dias_usados]);
return view(
'ausencia',
array_merge(
compact('tabela'),
['itens' => $ferias],
['dias_usados' => $dias_usados]
)
);
I setup my Webhok by Ngrok URL for my Facebook page, and I applied all of the requirements for the Messenger Platform, but when I send the messages to my Facebook page I encounter the following error:
POST /Facebook_Messenger_Token 500 Internal Server Error
and in routs file in Laravel I use Get and Post functions as follow:
Route::get('Facebook_Messenger_Token', 'MessengerController#index');
Route::post('Facebook_Messenger_Token', 'MessengerController#index');
When I send the messages I get the following error in storage/app.logs/laravel:
[2020-06-08 18:44:21] local.ERROR: Undefined variable: id {"exception":"[object] (ErrorException(code: 0): Undefined variable: id at C:\\xampp\\htdocs\\AzadApp\\app\\Http\\Controllers\\MessengerController.php:17)
[stacktrace]
my public function index:
public function index()
{
// here we can verify the webhook.
// i create a method for that.
$this->verifyAccess();
$user = json_decode($this->getUser($id)); --this is line 17
$input = json_decode(file_get_contents('php://input'), true);
$id = $input['entry'][0]['messaging'][0]['sender']['id'];
$message = $input['entry'][0]['messaging'][0]['message']['text'];
$response = [
'recipient' => ['id' => $id ],
'message' => ['text' => "Thanks for watching {$user->first_name} {$user->last_name}! :)"]
];
$this->sendMessage($response);
}
Please support and thanks.
The $id is being defined on line 19 (that is after line 17). in order to use it on
$user = json_decode($this->getUser($id));
you should place the above line after line 19
$id = $input['entry'][0]['messaging'][0]['sender']['id'];
do not move line 19 up (as i said in my comment) instead move line 17 down since
$id = $input['entry'][0]['messaging'][0]['sender']['id'];
is using $input that is defined before.
all you have to do is move line 17 under line 19.
so the full function now should look like this:
public function index()
{
// here we can verify the webhook.
// i create a method for that.
$this->verifyAccess();
$input = json_decode(file_get_contents('php://input'), true);
$id = $input['entry'][0]['messaging'][0]['sender']['id'];
$message = $input['entry'][0]['messaging'][0]['message']['text'];
$user = json_decode($this->getUser($id));
$response = [
'recipient' => ['id' => $id ],
'message' => ['text' => "Thanks for watching {$user->first_name} {$user->last_name}! :)"]
];
$this->sendMessage($response);
}
This question already has answers here:
Call to a member function on a non-object [duplicate]
(8 answers)
Closed 10 years ago.
I'm very new to CodeIgniter and not an expert in OOP so please bear with me.
This is the function I have in my model:
function get_company(int $user_id, $fields = '*'){
$r = $this->db->query("SELECT $fields FROM ".$this->db->dbprefix('companies')." WHERE user_id=?", $user_id)->row();
return $r;
}
function get_profile($user_id, $fields = '*'){
$r = $this->db->query("SELECT $fields FROM ".$this->db->dbprefix('users_profiles')." WHERE user_id=?", $user_id)->row();
return $r;
}
This is in my controller that is calling that model:
function index(){
$this->load->model('profiles_m');
$profile = $this->profiles_m->get_profile($this->access->getUid());
$company = $this->profile_m->get_company($this->access->getUid());
$vars = array(
'profile'=>$profile,
'company'=>$company,
);
$this->_getTemplate()->build('account', $vars);
}
An in my view:
$company = array(
'name' => 'company',
'id' => 'company',
'value' => "$company->name",
'class' => 'styl_f validate[required] text-input input-xlarge',
'placeholder' => "$company->name"
);
echo $company['value']
The error I am getting is this: Call to a member function get_company() on a non-object in C:\..\application\modules\accounts\controllers\accounts.php
I am under the impression that I am receiving these errors because I am passing a non object through get_company() but the thing that confuses me is that this error does not come up for get_profile(); The get_profile() function in my model is very similiar to my get_company() function. What is causing this error? How can I get rid of it?
The problem is within your controller:
function index(){
$this->load->model('profiles_m');
$profile = $this->profiles_m->get_profile($this->access->getUid());
$company = $this->profile_m->get_company($this->access->getUid()); // Right here
$vars = array(
'profile'=>$profile,
'company'=>$company,
);
$this->_getTemplate()->build('account', $vars);
}
The $profile variable uses $this->profiles_m as the object, but $company misses the letter 's' in the object.
Try with this line instead:
$company = $this->profiles_m->get_company($this->access->getUid());
You have a typo, the line should read:
$company = $this->profiles_m->get_company($this->access->getUid());
Notice 'profiles_m' and not 'profile_m'.
$company = $this->profile_m->get_company($this->access->getUid());
replace 'profile_m' to 'profiles_m'
I have probabbly a eal probleme with array . I have a request :
in my model
public function getHomme ($limit ,$offset)
{
$this->db->select('id,nom,prix,nom_marques,nom_path,quantite,semelle_interieure,libelle_fermeture,libelle_style,libelle_talon,libelle_doublure,libelle_semelle,libelle_dessus');
$this->db->from('chaussure');
$this->db->join('gnr_convenir', 'gnr_convenir.identifiant_chaussure = chaussure.id');
$this->db->join('images', 'images.id_chaussure = chaussure.id');
$this->db->join('marques', 'marques.idmarques = chaussure.identifiant_marques');
$this->db->join('fermeture', 'fermeture.idfermeture = chaussure.identifiant_fermeture');
$this->db->join('style', 'style.idstyle = chaussure.identifiant_style');
$this->db->join('talon', 'talon.idtalon = chaussure.identifiant_talon');
$this->db->join('doublure', 'doublure.iddoublure = chaussure.identifiant_doublure');
$this->db->join('materiauSemelle', 'materiauSemelle.idmateriauSemelle = chaussure.identifiant_semelle');
$this->db->join('dessus', 'dessus.iddessus = chaussure.identifiant_dessus');
$this->db->where('identifiant_genre', 1);
$this->db->order_by("id", "desc");
$this->db->limit($limit,$offset);
$query = $this->db->get();
$ligne= $query->num_rows();
if($query->num_rows()>0)
{
foreach($query->result()as $row)
{
$data[] = $row;
}
$data['ligne'] = $ligne;
return $data;
}
so here I need 2 things:
one the object on data and the other is $ligne (number of rows )
so it seems like this when I try to make var_dump($data)
array
'rows' =>
array
0 =>
object(stdClass)[21]
public 'id' => string '89' (length=2)
public 'nom' => string 'zoro' (length=4)
public 'prix' => string '12460.00' (length=8)
1 =>
object(stdClass)[22]
public 'id' => string '87' (length=2)
public 'nom' => string 'adizero' (length=7)
public 'prix' => string '124000.00' (length=9)
'ligne' => int 2
but when I try to write:
var_dump($data['ligne']) in my controller
I have an error message
A PHP Error was encountered
Severity: Notice
Message: Undefined index: ligne
Filename: controllers/client.php
Line Number: 143
null
I need those 2 data in my view, so in my view I thought to use $ligne like this:
$numberLigne = $ligne ;
As a test, could you echo ligne in your model to make sure that your join query is working right? I have no way of knowing without seeing your full table.
Also, any reason why you use:
if($query->num_rows()>0)
Instead of
if($ligne > 0):
Being that you just set that variable?