Welcome Guest, Not a member yet? Register   Sign In
Question about making sure an image is completely removed from your CRUD application
#6

@demyr  Thank you for your help. I used your solution and made small changes. and now it's working. I'll post the solution below.

The delete method used to remove data from the men's / boy's wrestling roster. The data is removed from both the database and filesystem. 
PHP Code:
    /**
    * DeleteRosterBoys Method | Remove data from rosterBoys
    */
    public function deleteRosterBoys(mixed $id null)
    {
        if ($this->request->getMethod() === 'delete') {

            $rosterboys = new RosterBoys();

            $findImage $rosterboys->find($id);
            $getImage $findImage['image'];
            
            
if (file_exists("assets/uploads/$getImage")) {

                unlink("assets/uploads/$getImage");

            };

            $rosterboys->delete($id);

            return redirect()->to(base_url('controlpanel'))->with('status''Men\'s roster Deleted sucessfully');
        };
    
Reply


Messages In This Thread
RE: Question about making sure an image is completely removed from your CRUD application - by Son of Troy - 07-16-2022, 03:28 PM



Theme © iAndrew 2016 - Forum software by © MyBB