Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 0 additions & 60 deletions .env.example

This file was deleted.

39 changes: 0 additions & 39 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1 @@
name: CI/CD Development
on :
push:
branches: [ main ]
pull_request:
branches: [ main ]

workflow_dispatch:

jobs:
web-deploy:
name: auto deploy
runs-on: ubuntu-latest

steps:
- name: get latest code
uses: actions/checkout@v3

- name: FTP Deploy
# You may pin to the exact commit or the version.
# uses: SamKirkland/FTP-Deploy-Action@8a24039354ee91000cb948cb4a1dbdf1a1b94a3c
uses: SamKirkland/FTP-Deploy-Action@v4.3.1
with:
# ftp server
server: ${{ secrets.FTP_SERVER }}
# ftp username
username: ${{ secrets.FTP_USERNAME }}
# ftp password
password: ${{ secrets.FTP_PASSWORD }}
# Server port to connect to (read your web hosts docs)
port: ${{ secrets.FTP_PORT }}
# protocol to deploy with - ftp, ftps, or ftps-legacy
protocol: ftp
# An array of glob patterns, these files will not be included in the publish/delete process
exclude: |
**/.git*
**/.git*/**
**/node_modules/**
**/vendor/**
**/storage/**
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ yarn-error.log
/.fleet
/.idea
/.vscode
/storage
/storage/framework
composer.lock
/.github/**
3 changes: 2 additions & 1 deletion app/Contracts/Interfaces/ArticleInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Contracts\Interfaces\Eloquent\StoreInterface;
use App\Contracts\Interfaces\Eloquent\UpdateInterface;

interface ArticleInterface extends GetInterface, StoreInterface, UpdateInterface, DeleteInterface
interface ArticleInterface extends GetInterface, StoreInterface, UpdateInterface, DeleteInterface
{

}
17 changes: 17 additions & 0 deletions app/Contracts/Interfaces/Master/RoleInterface.php

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ini jadi jadi pakai bawaan GetInterface atau mau bikin sendiri get function nya?

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Contracts\Interfaces\Master;

use App\Contracts\Interfaces\Eloquent\StoreInterface;
use App\Contracts\Interfaces\Eloquent\GetInterface;
use App\Contracts\Interfaces\Eloquent\UpdateInterface;
use App\Contracts\Interfaces\Eloquent\DeleteInterface;
use App\Contracts\Interfaces\Eloquent\ShowInterface;

interface RoleInterface extends StoreInterface, GetInterface, UpdateInterface, DeleteInterface, ShowInterface
{
public function get(?int $perPage = null): mixed;

public function restore(mixed $id): mixed;
}

17 changes: 17 additions & 0 deletions app/Contracts/Interfaces/Master/UnitInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Contracts\Interfaces\Master;

use App\Contracts\Interfaces\Eloquent\CustomPaginateInterface;
use App\Contracts\Interfaces\Eloquent\DeleteInterface;
use App\Contracts\Interfaces\Eloquent\GetInterface;
use App\Contracts\Interfaces\Eloquent\ShowInterface;
use App\Contracts\Interfaces\Eloquent\StoreInterface;
use App\Contracts\Interfaces\Eloquent\UpdateInterface;

interface UnitInterface extends GetInterface, StoreInterface, CustomPaginateInterface, ShowInterface, UpdateInterface, DeleteInterface
{
public function allDataTrashed(): mixed;

public function all(): mixed;
}
15 changes: 15 additions & 0 deletions app/Contracts/Interfaces/SettingInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace App\Contracts\Interfaces;

use App\Contracts\Interfaces\Eloquent\CustomPaginateInterface;
use App\Contracts\Interfaces\Eloquent\CustomQueryInterface;
use App\Contracts\Interfaces\Eloquent\GetInterface;
use App\Contracts\Interfaces\Eloquent\StoreInterface;
use App\Contracts\Interfaces\Eloquent\DeleteInterface;
use App\Contracts\Interfaces\Eloquent\ShowInterface;
use App\Contracts\Interfaces\Eloquent\UpdateInterface;
interface SettingInterface extends GetInterface, StoreInterface, UpdateInterface, DeleteInterface, ShowInterface, CustomQueryInterface, CustomPaginateInterface
{

}
56 changes: 56 additions & 0 deletions app/Contracts/Repositories/Master/RoleRepository.php

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coba check coment atas ya

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace App\Contracts\Repositories\Master;

use App\Contracts\Interfaces\Master\RoleInterface;
use App\Contracts\Repositories\BaseRepository;
use App\Models\Role;
use Illuminate\Foundation\Mix;

class RoleRepository extends BaseRepository implements RoleInterface
{
public function __construct(Role $role)
{
$this->model = $role;
}

public function get(?int $perPage = null): mixed
{
return $perPage ? $this->model->paginate($perPage) : $this->model->get();
}


public function show(mixed $id): mixed
{
return $this->model->find($id);
}

public function store(array $data): mixed
{
return $this->model->create($data);
}

// public function show(mixed $id): mixed
// {
// return $this->model->with('store')->withCount('roles')->find($id);
// }

public function update(mixed $id, array $data): mixed
{
return $this->show($id)->update($data);
}

public function delete(mixed $id): mixed
{
$role = $this->show($id);
return $role ? $role->delete() : false;
}

public function restore(mixed $id): mixed
{
$role = $this->model->withTrashed()->find($id);
return $role ? $role->restore() : false;
}


}
83 changes: 83 additions & 0 deletions app/Contracts/Repositories/Master/UnitRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

namespace App\Contracts\Repositories\Master;

use App\Models\Unit;
use App\Contracts\Repositories\BaseRepository;
use App\Contracts\Interfaces\Master\UnitInterface;


class UnitRepository extends BaseRepository implements UnitInterface
{

public function __construct(Unit $unit)
{
$this->model = $unit;
}

public function get(): mixed
{
return $this->model->get();
}

public function store(array $data): mixed
{
return $this->model->create($data);
}

public function customQuery(array $data): mixed
{
return $this->model->query()
->when(count($data) > 0, function ($query) use ($data){
foreach ($data as $index => $value){
$query->where($index, $value);
}
});
}

public function customPaginate(int $pagination = 10, int $page = 1, ?array $data): mixed
{
return $this->model->query()
->when(count($data) > 0, function ($query) use ($data){
if(isset($data["search"])){
$query->where(function ($query2) use ($data) {
$query2->where('name', 'like', '%' . $data["search"] . '%')
->orwhere('code', 'like', '%' . $data["search"] . '%');
});
unset($data["search"]);
}

foreach ($data as $index => $value){
$query->where($index, $value);
}
})
->paginate($pagination, ['*'], 'page', $page);
// ->appends(['search' => $request->search, 'year' => $request->year]);
}

public function show(mixed $id): mixed
{
return $this->model->find($id);
}

public function allDataTrashed(): mixed // Untuk mencari data yang dihapus
{
return $this->model->withTrashed()->get();
}

public function update(mixed $id, array $data): mixed
{
return $this->show($id)->update($data);
}

public function delete(mixed $id): mixed
{
return $this->model->destroy($id);
}

public function all(): mixed
{
return $this->model->all();
}

}
70 changes: 70 additions & 0 deletions app/Contracts/Repositories/SettingRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

namespace App\Contracts\Repositories;

use App\Contracts\Interfaces\SettingInterface;
use App\Models\Setting;
use Illuminate\Database\QueryException;

class SettingRepository extends BaseRepository implements SettingInterface
{
public function __construct(Setting $setting)
{
$this->model = $setting;
}

public function get(): mixed
{
return $this->model->all();
}

public function store(array $data): mixed
{
return $this->model->create($data);
}

public function show(mixed $id): mixed
{
return $this->model->query()->find($id);
}

public function update(mixed $id, array $data): mixed
{
return $this->model->find($id)->update($data);
}

public function delete(mixed $id): mixed
{
return $this->show($id)->delete();
}

public function customPaginate(int $pagination = 10, int $page = 1, ?array $data): mixed
{
return $this->model->query()
->with('store')
->when(count($data) > 0, function ($query) use ($data) {
if (isset($data["search"])) {
$query->where(function ($query2) use ($data) {
$query2->where('name', 'like', '%' . $data["search"] . '%');
});
unset($data["search"]);
}

foreach ($data as $index => $value) {
$query->where($index, $value);
}
})
->paginate($pagination, ['*'], 'page', $page);
// ->appends(['search' => $request->search, 'year' => $request->year]);
}

public function customQuery(array $data): mixed
{
return $this->model->query()
->when(count($data) > 0, function ($query) use ($data) {
foreach ($data as $index => $value) {
$query->where($index, $value);
}
});
}
}
Loading