You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
2.9 KiB
110 lines
2.9 KiB
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use fullMstr;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Requests\Masters\CreateRequest;
|
|
use App\Http\Requests\Masters\UpdateRequest;
|
|
|
|
class MasterController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the singleMstr.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return \Illuminate\View\View
|
|
*/
|
|
public function index(Request $request)
|
|
{
|
|
$singleMstrQuery = Master::query();
|
|
$singleMstrQuery->where('title', 'like', '%'.$request->get('q').'%');
|
|
$singleMstrQuery->orderBy('title');
|
|
$mstrCollections = $singleMstrQuery->paginate(25);
|
|
|
|
return view('masters.index', compact('mstrCollections'));
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new singleMstr.
|
|
*
|
|
* @return \Illuminate\View\View
|
|
*/
|
|
public function create()
|
|
{
|
|
$this->authorize('create', new Master);
|
|
|
|
return view('masters.create');
|
|
}
|
|
|
|
/**
|
|
* Store a newly created singleMstr in storage.
|
|
*
|
|
* @param \App\Http\Requests\Masters\CreateRequest $singleMstrCreateForm
|
|
* @return \Illuminate\Routing\Redirector
|
|
*/
|
|
public function store(CreateRequest $singleMstrCreateForm)
|
|
{
|
|
$singleMstr = $singleMstrCreateForm->save();
|
|
|
|
return redirect()->route('masters.show', $singleMstr);
|
|
}
|
|
|
|
/**
|
|
* Display the specified singleMstr.
|
|
*
|
|
* @param \App\Models\Master $singleMstr
|
|
* @return \Illuminate\View\View
|
|
*/
|
|
public function show(Master $singleMstr)
|
|
{
|
|
return view('masters.show', compact('singleMstr'));
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified singleMstr.
|
|
*
|
|
* @param \App\Models\Master $singleMstr
|
|
* @return \Illuminate\View\View
|
|
*/
|
|
public function edit(Master $singleMstr)
|
|
{
|
|
$this->authorize('update', $singleMstr);
|
|
|
|
return view('masters.edit', compact('singleMstr'));
|
|
}
|
|
|
|
/**
|
|
* Update the specified singleMstr in storage.
|
|
*
|
|
* @param \App\Http\Requests\Masters\UpdateRequest $singleMstrUpdateForm
|
|
* @param \fullMstr $singleMstr
|
|
* @return \Illuminate\Routing\Redirector
|
|
*/
|
|
public function update(UpdateRequest $singleMstrUpdateForm, Master $singleMstr)
|
|
{
|
|
$singleMstr->update($singleMstrUpdateForm->validated());
|
|
|
|
return redirect()->route('masters.show', $singleMstr);
|
|
}
|
|
|
|
/**
|
|
* Remove the specified singleMstr from storage.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \fullMstr $singleMstr
|
|
* @return \Illuminate\Routing\Redirector
|
|
*/
|
|
public function destroy(Request $request, Master $singleMstr)
|
|
{
|
|
$this->authorize('delete', $singleMstr);
|
|
|
|
$request->validate(['master_id' => 'required']);
|
|
|
|
if ($request->get('master_id') == $singleMstr->id && $singleMstr->delete()) {
|
|
return redirect()->route('masters.index');
|
|
}
|
|
|
|
return back();
|
|
}
|
|
}
|