MrRobot21
2 years ago
279
3
Laravel

How check if record is exit and soft delete

Posted 2 years ago by MrRobot21

Hi Awesome People

I'm working on a API, it's mostly about CRUD, i just came to know about laravel soft delete i have a lessons table and in my controller i'm deleting the record by id

    //delete a lesson by id
    public function destroy($id) 
    {
        $dlesson = Lesson::find(input::get('id'));

        $dlesson->delete();

        return $this->respondDeleted('Lesson deleted successfully');
    }

now i want to know how i should check whether the lesson exist or not if exist soft delete it, if not return lesson not found

Thnak You

Please sign in or create an account to participate in this conversation.