119 lines
2.6 KiB
PHP
119 lines
2.6 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Webkul\Attribute\Http\Controllers;
|
||
|
|
|
||
|
|
use Illuminate\Http\Request;
|
||
|
|
use Illuminate\Http\Response;
|
||
|
|
use Webkul\Attribute\Models\Attribute;
|
||
|
|
/**
|
||
|
|
* Catalog attribute controller
|
||
|
|
*
|
||
|
|
* @author Jitendra Singh <jitendra@webkul.com>
|
||
|
|
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
|
||
|
|
*/
|
||
|
|
class AttributeController extends Controller
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* Contains route related configuration
|
||
|
|
*
|
||
|
|
* @var array
|
||
|
|
*/
|
||
|
|
protected $_config;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Create a new controller instance.
|
||
|
|
*
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function __construct()
|
||
|
|
{
|
||
|
|
$this->_config = request('_config');
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Display a listing of the resource.
|
||
|
|
*
|
||
|
|
* @return \Illuminate\Http\Response
|
||
|
|
*/
|
||
|
|
public function index()
|
||
|
|
{
|
||
|
|
return view($this->_config['view']);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Show the form for creating a new resource.
|
||
|
|
*
|
||
|
|
* @return \Illuminate\Http\Response
|
||
|
|
*/
|
||
|
|
public function create()
|
||
|
|
{
|
||
|
|
return view($this->_config['view'], compact('roleItems'));
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Store a newly created resource in storage.
|
||
|
|
*
|
||
|
|
* @return \Illuminate\Http\Response
|
||
|
|
*/
|
||
|
|
public function store()
|
||
|
|
{
|
||
|
|
$this->validate(request(), [
|
||
|
|
'code' => ['required', 'unique:attributes,code', new \Webkul\Core\Contracts\Validations\Slug],
|
||
|
|
'name' => 'required',
|
||
|
|
'type' => 'required'
|
||
|
|
]);
|
||
|
|
|
||
|
|
Attribute::create(request()->all());
|
||
|
|
|
||
|
|
session()->flash('success', 'Attribute created successfully.');
|
||
|
|
|
||
|
|
return redirect()->route($this->_config['redirect']);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Show the form for editing the specified resource.
|
||
|
|
*
|
||
|
|
* @param int $id
|
||
|
|
* @return \Illuminate\Http\Response
|
||
|
|
*/
|
||
|
|
public function edit($id)
|
||
|
|
{
|
||
|
|
$role = Role::findOrFail($id);
|
||
|
|
|
||
|
|
return view($this->_config['view'], compact('role'));
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Update the specified resource in storage.
|
||
|
|
*
|
||
|
|
* @param \Illuminate\Http\Request $request
|
||
|
|
* @param int $id
|
||
|
|
* @return \Illuminate\Http\Response
|
||
|
|
*/
|
||
|
|
public function update(Request $request, $id)
|
||
|
|
{
|
||
|
|
$this->validate(request(), [
|
||
|
|
'name' => 'required',
|
||
|
|
'permission_type' => 'required',
|
||
|
|
]);
|
||
|
|
|
||
|
|
$role = Role::findOrFail($id);
|
||
|
|
|
||
|
|
$role->update(request()->all());
|
||
|
|
|
||
|
|
session()->flash('success', 'Role updated successfully.');
|
||
|
|
|
||
|
|
return redirect()->route($this->_config['redirect']);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Remove the specified resource from storage.
|
||
|
|
*
|
||
|
|
* @param int $id
|
||
|
|
* @return \Illuminate\Http\Response
|
||
|
|
*/
|
||
|
|
public function destroy($id)
|
||
|
|
{
|
||
|
|
//
|
||
|
|
}
|
||
|
|
}
|