mirror of
https://github.com/cp6/my-idlers.git
synced 2024-11-17 07:52:40 +01:00
d34223b5cd
Removed debugging
62 lines
1.6 KiB
PHP
62 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Providers;
|
|
use DataTables;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ProvidersController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$providers = Providers::all();
|
|
return view('providers.index', compact(['providers']));
|
|
}
|
|
|
|
public function create()
|
|
{
|
|
return view('providers.create');
|
|
}
|
|
|
|
public function store(Request $request)
|
|
{
|
|
$request->validate([
|
|
'provider_name' => 'required|min:2'
|
|
]);
|
|
|
|
Providers::create([
|
|
'name' => $request->provider_name
|
|
]);
|
|
|
|
return redirect()->route('providers.index')
|
|
->with('success', 'Provider Created Successfully.');
|
|
}
|
|
|
|
public function destroy(Providers $provider)
|
|
{
|
|
$items = Providers::find($provider->id);
|
|
|
|
$items->delete();
|
|
|
|
return redirect()->route('providers.index')
|
|
->with('success', 'Provider was deleted Successfully.');
|
|
}
|
|
|
|
public function getProviders(Request $request)
|
|
{
|
|
if ($request->ajax()) {
|
|
$data = Providers::latest()->get();
|
|
$dt = Datatables::of($data)
|
|
->addIndexColumn()
|
|
->addColumn('action', function($row){
|
|
$actionBtn = '<a href="javascript:void(0)" class="edit btn btn-success btn-sm">Edit</a> <a href="javascript:void(0)" class="delete btn btn-danger btn-sm">Delete</a>';
|
|
return $actionBtn;
|
|
})
|
|
->rawColumns(['action'])
|
|
->make(true);
|
|
}
|
|
}
|
|
|
|
}
|