vendredi 7 octobre 2016

Can't delete a record in Laravel 5

I'm having trouble in deleting a record that has file in it. Below is the code.

delete file method :

private function deletePDF(Journal $journal) {
        $exist = Storage::disk('file')->exists($journal->file);

        if (isset($journal->file) && $exist) {
            $delete = Storage::disk('file')->delete($journal->file);
            if ($delete) {
                return true;
            }
            return false;
        }
    }

Destroy method :

public function destroy(Journal $journal, EditionRequest $request) {
    $this->deletePDF($journal);
    $journal->delete();

    return redirect()->route('edition', ['id' => $request->id]);
}

The result game me nothing, it's just return to the page where the record belongs and does not deleting the record. I used the same code for another project with the same laravel version and it's working, but for some reasons it doesn't work here and I'm a lil bit confused.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire