I can't understand why it doesn't work, if the number is lower than 100000 everything works perfectly if I try to open this 684356 existing database it gives me this error, all higher numbers give me this error, lower numbers it works perfectly, from what does it depend?
An example if I open a category with number 31085 --> this works An example if I open a category with number 684356 --> Attempt to assign property "category_id" on null
Controller
public function editAttributes(Request $request, $category_id){
Session::put('page','tickets-log');
$category_logs = TicketsLog::find($request->category_id);
$category_logs->category_id= $request->category_id;
$category_logs->category_name = $request->category_name;
$category_logs->category_desc = $request->category_desc;
$category_logs->category_not = $request->category_not ;
$category_logs->category_not2 = $request->category_not2;
$category_logs->category_not3 = $request->category_not3;
$category_logs->category_not4 = $request->category_not4;
if($category_logs->save()){
return view('attributes.edit', compact('category_logs'));
}
}
Blade
<form enctype="multipart/form-data" action="{{url('edit-attributes')}}/{{ $category_logs->category_id }}" method="post">@csrf
<div >
<div >
<div >
<h5 >Category :</h5>
<input type="number" id="category_id" value="{{ $category_logs['category_id']}}" readonly="">
</div>
</div>
</div>
CodePudding user response:
I think the problem is the action attribute. Instead of
action="{{url('edit-attributes')}}/{{ $category_logs->category_id }}" put action="{{ url('edit-attributes',$category_logs->category_id ) }}".
I don't know how you defined the route.
If you have the {category_id}
attribute defined in the route, change
TicketsLog::find($request->category_id);
in
TicketsLog::find($category_id);
or If category_id isn't defined as primary key this table
TicketsLog::where('category_id','=',$category_id)->first();