Skip to content

Commit

Permalink
Taxonomy index create edit and delete pages (#172)
Browse files Browse the repository at this point in the history
Co-authored-by: Hasan10100 <[email protected]>
  • Loading branch information
kusaljayawardhana and Hasan10100 authored Oct 12, 2024
1 parent 999990a commit 66d0f0b
Show file tree
Hide file tree
Showing 10 changed files with 220 additions and 9 deletions.
45 changes: 45 additions & 0 deletions app/Http/Livewire/Backend/TaxonomyTable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace App\Http\Livewire\Backend;

use App\Domains\Taxonomy\Models\Taxonomy;
use Illuminate\Database\Eloquent\Builder;
use Rappasoft\LaravelLivewireTables\DataTableComponent;
use Rappasoft\LaravelLivewireTables\Views\Column;

class TaxonomyTable extends DataTableComponent
{
public array $perPageAccepted = [10, 25, 50];
public bool $perPageAll = true;

public string $defaultSortColumn = 'created_at';
public string $defaultSortDirection = 'desc';

public function columns(): array
{
return [
Column::make("Code", "code")
->searchable()->sortable(),
Column::make("Name", "name")
->searchable()->sortable(),
Column::make("Created by", "created_by")
->sortable(),
Column::make("Updated by", "updated_by")
->sortable(),
Column::make("Created at", "created_at")
->sortable(),
Column::make("Actions")
];
}

public function query(): Builder
{
return Taxonomy::query();
}

public function rowView(): string
{
return 'backend.taxonomies.index-table-row';
}
}

14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public function up()
$table->string('name', 191);
$table->string('description')->nullable();
$table->json('properties');
$table->foreignId('created_by')->constrained('users')->onUpdate('cascade')->onDelete('set null');
$table->foreignId('updated_by')->constrained('users')->onUpdate('cascade')->onDelete('set null');
$table->foreignId('created_by')->nullable()->constrained('users')->onUpdate('cascade')->onDelete('set null');
$table->foreignId('updated_by')->nullable()->constrained('users')->onUpdate('cascade')->onDelete('set null');
$table->timestamps();
});
}
Expand Down
Empty file.
31 changes: 31 additions & 0 deletions resources/views/backend/taxonomy/delete.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@extends('backend.layouts.app')

@section('title', __('Delete Taxonomy'))

@section('content')
<div>
<x-backend.card>
<x-slot name="header">
Taxonomy : Delete | {{ $taxonomy->id }}
</x-slot>

<x-slot name="body">
<p>Are you sure you want to delete
<strong><i>"{{ $taxonomy->name }}"</i></strong> ?
</p>
<div class="d-flex">
{!! Form::open([
'url' => route('dashboard.taxonomy.destroy', compact('taxonomy')),
'method' => 'delete',
'class' => 'container',
]) !!}

<a href="{{ route('dashboard.taxonomy.index') }}" class="btn btn-light mr-2">Back</a>
{!! Form::submit('Delete', ['class' => 'btn btn-danger']) !!}

{!! Form::close() !!}
</div>
</x-slot>
</x-backend.card>
</div>
@endsection
Empty file.
45 changes: 45 additions & 0 deletions resources/views/backend/taxonomy/index-table-row.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php use App\Domains\Auth\Models\User; ?>

<x-livewire-ttables::table.cell>
{{ $row->code }}
</x-livewire-tables::table.cell>

<x-livewire-tables::table.cell>
{{ $row->name }}
</x-livewire-tables::table.cell>

<x-livewire-tables::table.cell>
{{ User::find($row->created_by)->name ?? 'N/A' }}
</x-livewire-tables::table.cell>

<x-livewire-tables::table.cell>
{{ User::find($row->updated_by)->name ?? 'N/A' }}
</x-livewire-tables::table.cell>

<x-livewire-tables::table.cell>
<div class="d-flex px-0 mt-0 mb-0">
<div class="btn-group" role="group" aria-label="">

<!-- View Button -->
<a href="{{ route('taxonomy.view', $row->id) }}" class="btn btn-sm btn-primary">
<i class="fa fa-eye" title="View"></i>
</a>

<!-- Manage Button -->
<a href="{{ route('taxonomy.terms', $row->id) }}" class="btn btn-sm btn-secondary">
<i class="fa fa-list" title="Manage"></i>
</a>

<!-- Edit Button -->
<a href="{{ route('taxonomy.edit', $row->id) }}" class="btn btn-sm btn-warning">
<i class="fa fa-pencil" title="Edit"></i>
</a>

<!-- Delete Button -->
<a href="{{ route('taxonomy.delete', $row->id) }}" class="btn btn-sm btn-danger">
<i class="fa fa-trash" title="Delete"></i>
</a>

</div>
</div>
</x-livewire-tables::table.cell>
31 changes: 31 additions & 0 deletions resources/views/backend/taxonomy/index.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@extends('backend.layouts.app')

@section('title', __('Taxonomy'))

@section('content')
<div>
<x-backend.card>
<x-slot name="header">
Taxonomy
</x-slot>

<x-slot name="headerActions">
<x-utils.link icon="c-icon cil-plus" class="card-header-action" :href="route('dashboard.taxonomy.create')" :text="__('Create Taxonomy')">
</x-utils.link>
</x-slot>

<x-slot name="body">
@if (session('Success'))
<div class="alert alert-success">
{{ session('Success') }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
@endif

<livewire:backend.taxonomy-table />
</x-slot>
</x-backend.card>
</div>
@endsection
3 changes: 3 additions & 0 deletions resources/views/livewire/backend/taxonomy-table.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div>
{{-- Care about people's approval and you will be their prisoner. --}}
</div>
56 changes: 56 additions & 0 deletions routes/backend/taxonomy.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

use Tabuna\Breadcrumbs\Trail;
use App\Http\Controllers\Backend\TaxonomyController;
use Illuminate\Support\Facades\Route;

Route::group([], function () {

// Index
Route::get('taxonomy', function () {
return view('backend.taxonomy.index');
})->name('taxonomy.index')
->breadcrumbs(function (Trail $trail) {
$trail->push(__('Home'), route('dashboard.home'))
->push(__('Taxonomy'), route('dashboard.taxonomy.index'));
});

// Create
Route::get('taxonomy/create', [TaxonomyController::class, 'create'])
->name('taxonomy.create')
->breadcrumbs(function (Trail $trail) {
$trail->push(__('Home'), route('dashboard.home'))
->push(__('Taxonomy'), route('dashboard.taxonomy.index'))
->push(__('Create'));
});

// Store
Route::post('taxonomy', [TaxonomyController::class, 'store'])
->name('taxonomy.store');

// Edit
Route::get('taxonomy/edit/{taxonomy}', [TaxonomyController::class, 'edit'])
->name('taxonomy.edit')
->breadcrumbs(function (Trail $trail, $taxonomy) {
$trail->push(__('Home'), route('dashboard.home'))
->push(__('Taxonomy'), route('dashboard.taxonomy.index'))
->push(__('Edit'), route('dashboard.taxonomy.edit', $taxonomy));
});

// Update
Route::put('taxonomy/{taxonomy}', [TaxonomyController::class, 'update'])
->name('taxonomy.update');

// Delete
Route::get('taxonomy/delete/{taxonomy}', [TaxonomyController::class, 'delete'])
->name('taxonomy.delete')
->breadcrumbs(function (Trail $trail, $taxonomy) {
$trail->push(__('Home'), route('dashboard.home'))
->push(__('Taxonomy'), route('dashboard.taxonomy.index'))
->push(__('Delete'));
});

// Destroy
Route::delete('taxonomy/{taxonomy}', [TaxonomyController::class, 'destroy'])
->name('taxonomy.destroy');
});

0 comments on commit 66d0f0b

Please sign in to comment.