Changeset ff9da8b


Ignore:
Timestamp:
02/26/21 18:14:28 (4 years ago)
Author:
Berat Kjufliju <kufliju@…>
Branches:
master
Children:
7ed1069
Parents:
f457265
Message:

Added companies delete

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • app/Http/Controllers/Dashboard/CompaniesController.php

    rf457265 rff9da8b  
    33namespace App\Http\Controllers\Dashboard;
    44
     5use App\Helpers\Alert;
    56use App\Models\Company;
    67use Illuminate\Http\Request;
     
    2930        ]);
    3031    }
     32
     33    public function destroy($id)
     34    {
     35        $company = Company::findOrFail($id);
     36        $companyName = $company->name;
     37        $company->delete();
     38
     39        Alert::flash($companyName . " deleted successfully");
     40
     41        return redirect()->route("dashboard.companies.index");
     42    }
    3143}
  • database/migrations/2019_10_12_000000_create_users_table.php

    rf457265 rff9da8b  
    2525            $table->string('mobile_number')->unique();
    2626            $table->integer('company_id')->unsigned()->nullable();
    27             $table->foreign("company_id")->references("id")->on("companies");
     27            $table->foreign("company_id")->references("id")->on("companies")->onDelete("cascade");
    2828            $table->integer('role_id')->unsigned();
    2929            $table->foreign("role_id")->references("id")->on("roles");
  • resources/views/dashboard/companies/index.blade.php

    rf457265 rff9da8b  
    5050                                                        <a href="{{ route("dashboard.companies.create-admin", ["id" => $company->id]) }}" class="actionLink dropdown-item" style="cursor: pointer;"><i class="dropdown-icon fe fe-user"></i> Create admin user</a>
    5151                                                    @endif
    52                                                     <a href="javascript:void(0)" class="actionLink dropdown-item" style="cursor: pointer;" data-action="{{ route("dashboard.tags.destroy", ["id" => $company->id]) }}" data-method="delete"><i class="dropdown-icon fe fe-trash-2 text-danger"></i> Delete </a>
     52                                                    <a href="javascript:void(0)" class="actionLink dropdown-item" style="cursor: pointer;" data-action="{{ route("dashboard.companies.destroy", ["id" => $company->id]) }}" data-method="delete"><i class="dropdown-icon fe fe-trash-2 text-danger"></i> Delete </a>
    5353                                                </div>
    5454                                            </div>
Note: See TracChangeset for help on using the changeset viewer.