-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from balajidharma/2.x-Changes
Added attribute manager
- Loading branch information
Showing
7 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Admin; | ||
|
||
use App\Http\Controllers\Controller; | ||
use BalajiDharma\LaravelAdminCore\Actions\Attribute\AttributeCreateAction; | ||
use BalajiDharma\LaravelAdminCore\Actions\Attribute\AttributeUpdateAction; | ||
use BalajiDharma\LaravelAdminCore\Data\Attribute\AttributeCreateData; | ||
use BalajiDharma\LaravelAdminCore\Data\Attribute\AttributeUpdateData; | ||
use BalajiDharma\LaravelAdminCore\Grid\AttributeGrid; | ||
use BalajiDharma\LaravelAttributes\Models\Attribute; | ||
|
||
class AttributeController extends Controller | ||
{ | ||
/** | ||
* Display a listing of the resource. | ||
* | ||
* @return \Illuminate\View\View | ||
*/ | ||
public function index() | ||
{ | ||
$this->authorize('adminViewAny', Attribute::class); | ||
$attributes = (new Attribute)->newQuery(); | ||
$crud = (new AttributeGrid)->list($attributes); | ||
|
||
return view('admin.crud.index', compact('crud')); | ||
} | ||
|
||
/** | ||
* Show the form for creating a new resource. | ||
* | ||
* @return \Illuminate\View\View | ||
*/ | ||
public function create() | ||
{ | ||
$this->authorize('adminCreate', Attribute::class); | ||
$crud = (new AttributeGrid)->form(); | ||
|
||
return view('admin.crud.edit', compact('crud')); | ||
} | ||
|
||
/** | ||
* Store a newly created resource in storage. | ||
* | ||
* @return \Illuminate\Http\RedirectResponse | ||
*/ | ||
public function store(AttributeCreateData $data, AttributeCreateAction $attributeCreateAction) | ||
{ | ||
$this->authorize('adminCreate', Attribute::class); | ||
$attributeCreateAction->handle($data); | ||
|
||
return redirect()->route('admin.attribute.index') | ||
->with('message', 'Attribute created successfully.'); | ||
} | ||
|
||
/** | ||
* Display the specified resource. | ||
* | ||
* @return \Illuminate\View\View | ||
*/ | ||
public function show(Attribute $attribute) | ||
{ | ||
$this->authorize('adminView', $attribute); | ||
$crud = (new AttributeGrid)->show($attribute); | ||
|
||
return view('admin.crud.show', compact('crud')); | ||
} | ||
|
||
/** | ||
* Show the form for editing the specified resource. | ||
* | ||
* @param \BalajiDharma\LaravelAttributes\Models\Attribute $attribute | ||
* @return \Illuminate\View\View | ||
*/ | ||
public function edit(Attribute $attribute) | ||
{ | ||
$this->authorize('adminUpdate', $attribute); | ||
$crud = (new AttributeGrid)->form($attribute); | ||
|
||
return view('admin.crud.edit', compact('crud')); | ||
} | ||
|
||
/** | ||
* Update the specified resource in storage. | ||
* | ||
* @param \BalajiDharma\LaravelAttributes\Models\Attribute $attribute | ||
* @return \Illuminate\Http\RedirectResponse | ||
*/ | ||
public function update(AttributeUpdateData $data, Attribute $attribute, AttributeUpdateAction $attributeUpdateAction) | ||
{ | ||
$this->authorize('adminUpdate', $attribute); | ||
$attributeUpdateAction->handle($data, $attribute); | ||
|
||
return redirect()->route('admin.attribute.index') | ||
->with('message', 'Attribute updated successfully.'); | ||
} | ||
|
||
/** | ||
* Remove the specified resource from storage. | ||
* | ||
* @param \BalajiDharma\LaravelAttributes\Models\Attribute $attribute | ||
* @return \Illuminate\Http\RedirectResponse | ||
*/ | ||
public function destroy(Attribute $attribute) | ||
{ | ||
$this->authorize('adminDelete', $attribute); | ||
$attribute->delete(); | ||
|
||
return redirect()->route('admin.attribute.index') | ||
->with('message', __('Attribute deleted successfully')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters