Commit although could not run on localhost

This commit is contained in:
Obenny
2020-10-08 14:49:49 +08:00
parent fcfe19f0fa
commit 50a69439a1
9 changed files with 273 additions and 0 deletions
@@ -0,0 +1,31 @@
<?php
namespace App\Http\Controllers\Announcement;//call to announcement controller folder
use App\Http\Controllers\Controller;//call to controller class
use App\Models\Announcement;
use Illuminate\Http\Request;
class DeleteAnnouncementController extends Controller
{
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$announcement = Announcement::findOrFail($id);
$deleted = $announcement->delete();
if($deleted)
{
session()->put('success', 'Announcement Successfully Deleted!');
return redirect()->back();
}
//the else part
session()->put('error', 'There was an error deleting this announcement!');
return redirect()->back();
}
}