Answer the question
In order to leave comments, you need to log in
Why doesn't delete work in laravel?
Hello. In fact, the problem has already been solved, but I am haunted by the fact that I could have solved it incorrectly. And in general, the very fact that I don’t understand how and what works (until the end)
The bottom line is this
. I have an axios request to the controller:
axios.post('/deletefolderntd', {id: this.fornewfolder[0].id}).then(response => {
console.log(response.data);
});
Route::post('/deletefolderntd', '[email protected]');
public function deleteFolder(Request $request) {
$id = $request->id;
$model = new Filemanager();
$result = $model->deleteFolderById($id);
}
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Filemanager extends Model {
protected $table = 'folders';
protected $connection = 'sqlite';
public function deleteFolderById($id) {
return $this->where('id', $id)->delete();
}
}
public function deleteFolder(Request $request) {
$id = $request->id;
$model = Filemanager::find($id);
$result = $model->delete();
}
Answer the question
In order to leave comments, you need to log in
Can it be otherwise
public function destroy(Request $r) {
return Filemanager::destroy($r->id);
}
php artisan route:list
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question