Optimize code
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Modules\Lpj\Exports\BranchExport;
|
||||
@@ -29,7 +30,7 @@
|
||||
return redirect()
|
||||
->route('basicdata.branch.index')
|
||||
->with('success', 'Branch created successfully');
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('basicdata.branch.create')
|
||||
->with('error', 'Failed to create branch');
|
||||
@@ -60,7 +61,7 @@
|
||||
return redirect()
|
||||
->route('basicdata.branch.index')
|
||||
->with('success', 'Branch updated successfully');
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
return redirect()
|
||||
->route('basicdata.branch.edit', $id)
|
||||
->with('error', 'Failed to update branch');
|
||||
@@ -76,7 +77,7 @@
|
||||
$branch->delete();
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Branch deleted successfully']);
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => 'Failed to delete branch']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user