我正在尝试保存到数据库中,但我经常遇到此错误
调用未定义的方法stdClass :: save()
我的控制器
$c = DB::table('subject_user')->where('user_id', $value)->first();
$c->auth_teacher = '1';
$c->save();
Run Code Online (Sandbox Code Playgroud) 我收到这个错误:
非静态方法 Illuminate\Database\Eloquent\Model::delete() 不应静态调用,假设 $this 来自不兼容的上下文
这是我的控制器中的代码:
$file_db = new File();
$file_db = $file_db->where('id',$id)->find($id);
$file_db = $file_db->delete();
Run Code Online (Sandbox Code Playgroud)
有人可以解释我做错了什么以及如何正确调用它吗?
我正在尝试使用将我的应用程序移动到纯反应的redux反应。我为onClick做了一个动作和减速器,但是尝试以开发模式启动应用程序后,出现此错误
Uncaught TypeError: Cannot read property 'type' of undefined at reducerDomMethods (manMethodsReducers.js:12)
Run Code Online (Sandbox Code Playgroud)
这是这条线
switch (action.type) {
Run Code Online (Sandbox Code Playgroud)
这是我的代码
减速器
export default function reducerDomMethods(state={
isClicked: false,
}, action) {
switch (action.type) {
case "CLICK_OPEN": {
return {
...state,
isClicked: true
}
}
case "CLICK_CLOSE": {
return{
...state,
isClicked:false
}
}
return state;
}
}
Run Code Online (Sandbox Code Playgroud)
行动
export function clicking(isClicked) {
return function (dispatch) {
if( isClicked === true){
dispatch({type: "CLICK_OPEN",isClicked: true});
}else {
dispatch({type: "CLICK_CLOSE",isClicked: false});
}
}
}
Run Code Online (Sandbox Code Playgroud)
联合减速机
import { combineReducers …Run Code Online (Sandbox Code Playgroud) 我在我的控制器中有文件上传,需要在我的文件末尾添加 carbon,以便我可以将它作为唯一的插入到数据库中。我这样做
$upload->title = Auth::User()->id;
$current = Carbon::now();
$file = $request->file('file');
$file->move(storage_path(). '/', $file->getClientOriginalName());
$upload->name = $file->getClientOriginalName().$current;
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,当向用户展示它时,如何将其删除,以便用户只能看到文件原始名称(使用 php 我可以做到,但我想使用“laravel 方式”)
如何设置引导按钮的自定义宽度。
我的问题是我不知道如何缩小按钮的宽度以喜欢图像(这是一个提交按钮)。左侧部分是输入文本。我的问题是按钮太宽了。这是代码:
<div class="col-xs-5 col-xs-offset-3">
<div class="input-group input-group-lg">
<input type="text" class="form-control input-lg input-forme" id="Text" placeholder="Text">
<span class="input-group-btn tipka">
<button type="submit" class="btn btn-group-small" id="form-submit">Submit</button>
</span>
</div>
</div>
Run Code Online (Sandbox Code Playgroud) $.ajax({
url: '{{ URL('reports/groupsUsersGet') }}',
dataType: "json",
data: {
group_id : $('#group').val(),
},
success: function(data) {
<li>"i want to insert variable here"<li>
},
error: function (data) {
console.log('Error:', data);
}
});
Run Code Online (Sandbox Code Playgroud)
控制器返回此
return Response::json($results);
Run Code Online (Sandbox Code Playgroud)
它给了这个
{"results":[{"id":1,"name":"user","nick":"user1"}]}
Run Code Online (Sandbox Code Playgroud)
我如何在ajax部分访问它
我有一个字符串,需要使用 map 函数将其转换为大写。它会是这样的:
var str = 'hello world how ya doing?';
function toUpperCase(str){
return str.split('').map((v,i) => i%2 == 0 ? v[i].toLowerCase(): v[i].toUpperCase()).join('');
}
console.log(toUpperCase(str));Run Code Online (Sandbox Code Playgroud)
但是当我运行它时,我得到了大写的整个句子。
laravel ×4
laravel-5 ×4
javascript ×3
php ×3
ecmascript-6 ×2
laravel-5.2 ×2
css ×1
eloquent ×1
html ×1
jquery ×1
json ×1
php-carbon ×1
react-redux ×1
reactjs ×1
redux ×1