-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
User link table from spesified user (#986)
- Loading branch information
Showing
7 changed files
with
174 additions
and
6 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
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,100 @@ | ||
<?php | ||
|
||
namespace App\Livewire\Table; | ||
|
||
use App\Models\Url; | ||
use Illuminate\Database\Eloquent\Builder; | ||
use PowerComponents\LivewirePowerGrid\Column; | ||
use PowerComponents\LivewirePowerGrid\Footer; | ||
use PowerComponents\LivewirePowerGrid\Header; | ||
use PowerComponents\LivewirePowerGrid\PowerGrid; | ||
use PowerComponents\LivewirePowerGrid\PowerGridComponent; | ||
use PowerComponents\LivewirePowerGrid\PowerGridFields; | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
final class UrlListOfUsersTable extends PowerGridComponent | ||
{ | ||
const STR_LIMIT = 95; | ||
|
||
public int $user_id; | ||
|
||
public int $perPage = 25; | ||
|
||
public bool $showUpdateMessages = true; | ||
|
||
public string $sortDirection = 'desc'; | ||
|
||
public function setUp(): array | ||
{ | ||
return [ | ||
Header::make() | ||
->showToggleColumns() | ||
->showSearchInput(), | ||
Footer::make() | ||
->showPerPage($this->perPage) | ||
->showRecordCount('full'), | ||
]; | ||
} | ||
|
||
public function datasource(): Builder | ||
{ | ||
return Url::where('user_id', $this->user_id); | ||
} | ||
|
||
public function fields(): PowerGridFields | ||
{ | ||
return PowerGrid::fields() | ||
->add('keyword', function (Url $url) { | ||
return view('components.table.keyword', ['url' => $url]) | ||
->render(); | ||
}) | ||
->add('destination', function (Url $url) { | ||
return view('components.table.destination', [ | ||
'url' => $url, | ||
'limit' => self::STR_LIMIT, | ||
])->render(); | ||
}) | ||
->add('t_clicks', function (Url $url) { | ||
return view('components.table.visit', ['url' => $url]) | ||
->render(); | ||
}) | ||
->add('created_at_formatted', function (Url $url) { | ||
return view('components.table.date-created', ['url' => $url]) | ||
->render(); | ||
}) | ||
->add('action', function (Url $url) { | ||
return view('components.table.action-button', ['url' => $url]) | ||
->render(); | ||
}); | ||
} | ||
|
||
/** | ||
* @return array<\PowerComponents\LivewirePowerGrid\Column> | ||
*/ | ||
public function columns(): array | ||
{ | ||
return [ | ||
Column::make('Short URL', 'keyword') | ||
->sortable() | ||
->searchable(), | ||
|
||
Column::make('Destination URL', 'destination') | ||
->sortable() | ||
->searchable(), | ||
Column::make('title', 'title') | ||
->searchable() | ||
->hidden(), | ||
|
||
Column::make('CLICKS', 't_clicks'), | ||
|
||
Column::make('CREATED AT', 'created_at_formatted', 'created_at') | ||
->searchable() | ||
->sortable(), | ||
|
||
Column::make('ACTIONS', 'action') | ||
->bodyAttribute(styleAttr: ';padding-left: 8px'), | ||
]; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
@extends('layouts.backend') | ||
|
||
@section('title', __('Links').' > '. $authorName) | ||
|
||
@section('content') | ||
<main> | ||
<div class="common-card-style"> | ||
<div class="card_header__v2"> | ||
<div class="w-1/2"> | ||
<span class="text-2xl text-uh-1"> | ||
{{__('Links created by')}} {{$authorName}} | ||
</span> | ||
</div> | ||
</div> | ||
|
||
@include('partials/messages') | ||
|
||
@livewire('table.UrlListOfUsersTable', ['user_id' => $authorId]) | ||
</div> | ||
</main> | ||
@endsection |
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,5 @@ | ||
<span class="font-semibold"> | ||
<a href="{{ route('dashboard.allurl.u-user', $url->author->name) }}"> | ||
{{ $url->author->name }} | ||
</a> | ||
</span> |
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