Bonjour,
je suis les tuto creer un site web avec cake php et j'ai un probleme avec afterfind :
Strict (2048): Declaration of Post::afterFind() should be compatible with Model::afterFind($results, $primary = false) [APP\Model\Post.php, line 2]
J'ai lu sur des forum qui fallait ajouter $results, $primary = false à mon afterFind mais ca merche toujours pas ...
Post.php :
<?php
class Post extends AppModel{
public function afterFind($data,$results, $primary = false){
foreach($data as $k=>$d){
if(isset($d['Post']['slug']) && isset($d['Post']['id'])){
$d['Post']['link'] = array(
'controller' => 'pages',
'action' => 'show',
'id' => $d['Post']['id'],
'slug' => $d['Post']['slug']
);
}
$data[$k] = $d;
}
return $data;
}
}
Merci d'avance
Bonjour.
Modifies par ceci :
public function afterFind($results, $primary = false){
foreach($results as $k=>$d){
if(isset($d['Post']['slug']) && isset($d['Post']['id'])){
$d['Post']['link'] = array(
'controller' => 'pages',
'action' => 'show',
'id' => $d['Post']['id'],
'slug' => $d['Post']['slug']
);
}
$results[$k] = $d;
}
return $results;
}