Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel model transaction

DB::beginTransaction();
        try {
            $project = Project::find($id);
            $project->users()->detach();
            $project->delete();
            DB::commit();
        } catch (Exception $ex) {
            DB::rollback();
            return response()->json(['error' => $ex->getMessage()], 500);
        }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #laravel #model #transaction
ADD COMMENT
Topic
Name
5+4 =