저는 PHP laravel 프레임 워크를 사용하여 웹 응용 프로그램을 만들고 있습니다. 모델을 데이터베이스에 저장하면 삽입되지만 모델 특성은 저장하지 않습니다. laravel 로그에 실수가 표시되지 않기 때문에 수정 방법을 볼 수 없습니다. 어떤 생각?Laravel with Eloquent가 데이터베이스의 모델 속성을 저장하지 않습니다.
모델 있습니다 :
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'test';
// protected $fillable = array('name', 'surname', 'mobile', 'phone', 'mail', 'adress');
// Model properties
private $name;
private $surname;
private $mobile;
private $phone;
private $mail;
private $adress;
// Model constructor
function __construct($name, $surname, $mobile, $phone, $mail, $adress) {
$this->name = $name;
$this->surname = $surname;
$this->mobile = $mobile;
$this->phone = $phone;
$this->mail = $mail;
$this->adress = $adress;
}
그리고 사용자 개체를 만들고 내가 화면에 모델 속성과 차종을 PHP 코드 쇼를 실행하면 데이터베이스
<?php
// Create an object using model's constructor
$user = new User('John', 'Doe', 685412578, 9354784125, '[email protected]', 'Portland');
// Show some properties
echo '<p>'.$user->getName().'</p>';
echo '<p>'.$user->getSurname().'</p>';
// Saving model on database
$user->save();
?>
에 저장 PHP 코드가있다 삽입하지만 속성을 저장하지 않습니다. 누군가가
있다가 솔루션입니다 나를 :) 도울 수 있다면 좋을 것 (사람이 같은 문제 또는 유사한있는 경우)
모델 :
protected $table = 'test';
// Fields on databse to save model properties
protected $fillable = array('name', 'surname', 'mobile', 'phone', 'mail', 'adress');
// Model properties
private $name;
private $surname;
private $mobile;
private $phone;
private $mail;
private $adress;
와 PHP 코드 :
<?php
// Create an object
$user = User::create(array(
'name'=>'John',
'surname'=>'Doe',
'mobile'=>685412578,
'phone'=>9354784125,
'mail'=>'[email protected]',
'adress'=>'Portland'
));
// Show some properties
echo '<p>'.$user->name.'</p>';
echo '<p>'.$user->surname.'</p>';
// Saving model on database
$user->save();
?>
lowerends와 watcher 모두에게 맞는 것이 고맙습니다. 현재 작동 중입니다. 고마워요! – proktovief