我想运行技能功能,但我不能.
Route.php
Route::get('setting',function(){
return \App\User::first()->skills();
});
Run Code Online (Sandbox Code Playgroud)
user.php的
protected $casts = [
'skills' => 'json'
];
public function skills(){
return new Skills($this , $this->skills);
}
Run Code Online (Sandbox Code Playgroud)
Skills.php
namespace App;
use App\User;
use Mockery\Exception;
class Skills
{
protected $user;
protected $skills = [];
public function __construct(User $user,array $skills){
$this->user=$user;
$this->skills=$skills;
}
}
Run Code Online (Sandbox Code Playgroud)
我想进入/设置页面我有" The Response content must be a string or object implementing __toString(), "object" given."错误.
我尝试dd()在路由中添加函数的返回,我看到所有JSON数据但是$skills->get(),$skill->set()当时没有工作.
编辑:
Skills.php
<?php
/**
* Created by PhpStorm.
* …Run Code Online (Sandbox Code Playgroud)