Last change
on this file since ff9da8b was ff9da8b, checked in by Berat Kjufliju <kufliju@…>, 4 years ago |
Added companies delete
|
-
Property mode
set to
100644
|
File size:
1017 bytes
|
Rev | Line | |
---|
[f457265] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | namespace App\Http\Controllers\Dashboard;
|
---|
| 4 |
|
---|
[ff9da8b] | 5 | use App\Helpers\Alert;
|
---|
[f457265] | 6 | use App\Models\Company;
|
---|
| 7 | use Illuminate\Http\Request;
|
---|
| 8 | use App\Http\Controllers\Controller;
|
---|
| 9 |
|
---|
| 10 | class CompaniesController extends Controller
|
---|
| 11 | {
|
---|
| 12 | public function index()
|
---|
| 13 | {
|
---|
| 14 | return view("dashboard.companies.index")->with([
|
---|
| 15 | "companies" => Company::all()
|
---|
| 16 | ]);
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | public function createAdmin($id)
|
---|
| 20 | {
|
---|
| 21 | $company = Company::findOrFail($id);
|
---|
| 22 |
|
---|
| 23 | if($company->users->count()) {
|
---|
| 24 | return redirect()->route("dashboard.companies.index");
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | return view("dashboard.companies.create-admin")->with([
|
---|
| 28 | "company" => $company,
|
---|
| 29 | "countries" => country()->all()
|
---|
| 30 | ]);
|
---|
| 31 | }
|
---|
[ff9da8b] | 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 | }
|
---|
[f457265] | 43 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.