Skip to content

Commit

Permalink
Merge pull request #57 from tomatophp/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
3x1io authored Mar 30, 2024
2 parents faa7a12 + cfdfe46 commit 1f807a4
Show file tree
Hide file tree
Showing 67 changed files with 2,993 additions and 60 deletions.
Binary file added .DS_Store
Binary file not shown.
26 changes: 26 additions & 0 deletions Modules/CircleApps/App/Http/Controllers/CircleAppsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Modules\CircleApps\App\Models\App;
use Nwidart\Modules\Facades\Module;
use ProtoneMedia\Splade\Facades\Toast;

class CircleAppsController extends Controller
Expand Down Expand Up @@ -100,6 +101,16 @@ public function show(App $app)

public function install(App $app)
{
if($app->required){
$checkRequiredApps = auth('accounts')->user()->apps()->whereIn('id', $app->required)->count();
if($checkRequiredApps !== count($app->required)){
$appRequired = App::whereIn('id', $app->required)->first();

auth('accounts')->user()->apps()->attach($appRequired->id);
}
}


if($app->account_id && $app->account_id !== auth('accounts')->id()){
$app->account->notifyDB(
message: __(auth('accounts')->user()->username . " " . __('is install your app') .' '. $app->name),
Expand All @@ -115,6 +126,21 @@ public function install(App $app)

public function uninstall(App $app)
{
$appRequiredThisApp = App::whereJsonContains('required', (string)$app->id)->get();
if($appRequiredThisApp->count() > 0){
$getRequiredApp = null;
foreach ($appRequiredThisApp as $requiredApp){
if(has_app($requiredApp->key)){
$getRequiredApp = $requiredApp;
}
}

if($getRequiredApp){
Toast::danger(__('You need to uninstall required apps first!'))->autoDismiss(2);
return redirect()->to(url('apps/'.$getRequiredApp->id));
}
}

if($app->account_id && $app->account_id !== auth('accounts')->id()){
$app->account->notifyDB(
message: __(auth('accounts')->user()->username . " " . __('is Uninstall your app') .' '. $app->name),
Expand Down
4 changes: 3 additions & 1 deletion Modules/CircleApps/App/Models/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ class App extends Model implements HasMedia
'price_per',
'discount',
'discount_to',
'required',
'is_free'
];

protected $casts = [
'is_active' => 'boolean',
'is_free' => 'boolean'
'is_free' => 'boolean',
'required' => 'json',
];

public function account()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('apps', function (Blueprint $table) {
$table->json('required')->nullable();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('apps', function (Blueprint $table) {
$table->dropColumn('required');
});
}
};
7 changes: 6 additions & 1 deletion Modules/CircleApps/resources/views/apps/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@
<x-splade-input :label="__('Github')" name="github" type="text" :placeholder="__('Github')" />
<x-splade-input :label="__('Privacy')" name="privacy" type="text" :placeholder="__('Privacy')" />
<x-splade-input :label="__('Faq')" name="faq" type="text" :placeholder="__('Faq')" />

<x-splade-select class="col-span-2" :label="__('App Required Other Apps?')" :placeholder="__('App Required Other Apps?')" name="required" multiple choices>
@php $apps = \Modules\CircleApps\App\Models\App::where('is_active', true)->get(); @endphp
@foreach($apps as $app)
<option value="{{$app->id}}">{{$app->name}}</option>
@endforeach
</x-splade-select>

<div class="flex justify-start gap-2 pt-3 col-span-2">
<x-tomato-admin-submit label="{{__('Save')}}" :spinner="true" />
Expand Down
7 changes: 6 additions & 1 deletion Modules/CircleApps/resources/views/apps/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@
<x-splade-input :label="__('Github')" name="github" type="text" :placeholder="__('Github')" />
<x-splade-input :label="__('Privacy')" name="privacy" type="text" :placeholder="__('Privacy')" />
<x-splade-input :label="__('Faq')" name="faq" type="text" :placeholder="__('Faq')" />

<x-splade-select class="col-span-2" :label="__('App Required Other Apps?')" :placeholder="__('App Required Other Apps?')" name="required" multiple choices>
@php $apps = \Modules\CircleApps\App\Models\App::where('is_active', true)->get(); @endphp
@foreach($apps as $app)
<option value="{{$app->id}}">{{$app->name}}</option>
@endforeach
</x-splade-select>

<div class="flex justify-start gap-2 pt-3">
<x-tomato-admin-submit label="{{__('Save')}}" :spinner="true" />
Expand Down
31 changes: 21 additions & 10 deletions Modules/CircleApps/resources/views/components/app-card.blade.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
<div class="bg-zinc-800 rounded-lg overflow-hidden shadow-md border border-zinc-700 p-4 min-w-64 min-h-56 flex flex-col gap-3">
<div class="flex justify-start gap-4">
<div style="background-image: url('{{$item->getMedia('logo')->first()?->getUrl()}}')" class="bg-cover bg-center w-16 h-16 rounded-lg">
<div class="flex justify-between gap-4">
<div class="flex justify-start gap-4">
<div style="background-image: url('{{$item->getMedia('logo')->first()?->getUrl()}}')" class="bg-cover bg-center w-16 h-16 rounded-lg border border-gray-700">

</div>
<x-splade-link :href="route('apps.show', $item)" class="flex justify-center flex-col items-center">
<div>
<h1 class="font-bold">{{$item->name}}</h1>
@if($item->account)
<x-splade-link class="text-zinc-400" href="{{url($item->account->username)}}">{{$item->account->name}}</x-splade-link>
</div>
<x-splade-link :href="route('apps.show', $item)" class="flex justify-center flex-col items-center">
<div>
<h1 class="font-bold">{{$item->name}}</h1>
@if($item->account)
<x-splade-link class="text-zinc-400" href="{{url($item->account->username)}}">{{$item->account->name}}</x-splade-link>
@endif
</div>
</x-splade-link>
</div>
<div>
@if(auth('accounts')->user())
@if(!has_app($item->key))
<x-splade-link :href="route('apps.install', $item)" method="POST" class="bg-success-600 text-zinc-100 rounded-full px-2 py-1 text-xs">{{__('Install')}}</x-splade-link>
@else
<x-splade-link :href="route('apps.uninstall', $item)" method="POST" confirm-danger class="bg-danger-600 text-zinc-100 rounded-full px-2 py-1 text-xs">{{__('Uninstall')}}</x-splade-link>
@endif
</div>
</x-splade-link>
@endif
</div>
</div>
<div>
@if($item->is_free)
Expand Down
6 changes: 6 additions & 0 deletions Modules/CircleApps/resources/views/submit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
<x-splade-input :label="__('Github')" name="github" type="text" :placeholder="__('Github')" />
<x-splade-input :label="__('Privacy')" name="privacy" type="text" :placeholder="__('Privacy')" />
<x-splade-input :label="__('Faq')" name="faq" type="text" :placeholder="__('Faq')" />
<x-splade-select class="col-span-2" :label="__('App Required Other Apps?')" :placeholder="__('App Required Other Apps?')" name="required" multiple choices>
@php $apps = \Modules\CircleApps\App\Models\App::where('is_active', true)->get(); @endphp
@foreach($apps as $app)
<option value="{{$app->id}}">{{$app->name}}</option>
@endforeach
</x-splade-select>

<div class="flex justify-start gap-2 pt-3 col-span-2">
<x-tomato-admin-submit label="{{__('Save')}}" :spinner="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Support\ServiceProvider;
use Modules\CircleApps\App\Facades\CircleAppsMenu;
use Modules\CircleContacts\App\Console\CircleContactsInstall;
use Modules\CircleContacts\App\Console\CircleInovicesInstall;
use TomatoPHP\TomatoAdmin\Services\Contracts\Menu;

class CircleContactsServiceProvider extends ServiceProvider
Expand Down
44 changes: 0 additions & 44 deletions Modules/CircleContacts/resources/views/contacts/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,47 +21,3 @@
</div>
@endif
@endsection

{{--<x-circle-xo-profile-layout>--}}
{{-- {{ __('CircleXoContact') }}--}}

{{-- <x-tomato-admin-button :modal="true" :href="route('profile.contacts.create')" type="link">--}}
{{-- {{trans('tomato-admin::global.crud.create-new')}} {{__('CircleXoContact')}}--}}
{{-- </x-tomato-admin-button>--}}

{{-- <div class="pb-12">--}}
{{-- <div class="mx-auto">--}}
{{-- <x-splade-table :for="$table" striped>--}}
{{-- <x-splade-cell email>--}}
{{-- <x-tomato-admin-row table type="email" :value="$item->email" />--}}
{{-- </x-splade-cell>--}}
{{-- <x-splade-cell phone>--}}
{{-- <x-tomato-admin-row table type="tel" :value="$item->phone" />--}}
{{-- </x-splade-cell>--}}
{{-- <x-splade-cell account_id>--}}
{{-- <x-tomato-admin-row table type="number" :value="$item->account_id" />--}}
{{-- </x-splade-cell>--}}

{{-- <x-splade-cell actions>--}}
{{-- <div class="flex justify-start">--}}
{{-- <x-tomato-admin-button success type="icon" title="{{trans('tomato-admin::global.crud.view')}}" modal :href="route('profile.contacts.show', $item->id)">--}}
{{-- <x-heroicon-s-eye class="h-6 w-6"/>--}}
{{-- </x-tomato-admin-button>--}}
{{-- <x-tomato-admin-button warning type="icon" title="{{trans('tomato-admin::global.crud.edit')}}" modal :href="route('profile.contacts.edit', $item->id)">--}}
{{-- <x-heroicon-s-pencil class="h-6 w-6"/>--}}
{{-- </x-tomato-admin-button>--}}
{{-- <x-tomato-admin-button danger type="icon" title="{{trans('tomato-admin::global.crud.delete')}}" :href="route('profile.contacts.destroy', $item->id)"--}}
{{-- confirm="{{trans('tomato-admin::global.crud.delete-confirm')}}"--}}
{{-- confirm-text="{{trans('tomato-admin::global.crud.delete-confirm-text')}}"--}}
{{-- confirm-button="{{trans('tomato-admin::global.crud.delete-confirm-button')}}"--}}
{{-- cancel-button="{{trans('tomato-admin::global.crud.delete-confirm-cancel-button')}}"--}}
{{-- method="delete"--}}
{{-- >--}}
{{-- <x-heroicon-s-trash class="h-6 w-6"/>--}}
{{-- </x-tomato-admin-button>--}}
{{-- </div>--}}
{{-- </x-splade-cell>--}}
{{-- </x-splade-table>--}}
{{-- </div>--}}
{{-- </div>--}}
{{--</x-circle-xo-profile-layout>--}}
Binary file added Modules/CircleInvoices/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions Modules/CircleInvoices/.github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: [3x1io]
Empty file.
65 changes: 65 additions & 0 deletions Modules/CircleInvoices/App/Console/CircleInvoicesInstall.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace Modules\CircleInvoices\App\Console;

use Illuminate\Console\Command;
use Modules\CircleApps\App\Models\App;
use TomatoPHP\ConsoleHelpers\Traits\RunCommand;

class CircleInvoicesInstall extends Command
{
use RunCommand;

/**
* The name and signature of the console command.
*
* @var string
*/
protected $name = 'circle-invoices:install';

/**
* The console command description.
*
* @var string
*/
protected $description = 'install package and publish assets';

public function __construct()
{
parent::__construct();
}


/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->info('Install App');
$app = App::where('key', 'circle-invoices')->first();
if(!$app){
$app = new App();
$app->key = 'circle-invoices';
$app->name = 'Circle Invoices';
$app->description = 'Invoices Generator With Custom Templates, to generate public invoices and your customer can download it';
$app->is_active = true;
$app->is_free = true;
$app->status = "active";
$app->homepage = "https://www.github.com/tomatophp/circle-invoices";
$app->github = "https://www.github.com/tomatophp/circle-invoices";
$app->docs = "https://www.github.com/tomatophp/circle-invoices";
$app->privacy = "https://www.github.com/tomatophp/circle-invoices";
$app->faq = "https://www.github.com/tomatophp/circle-invoices";
$app->email = "[email protected]";
$getContactsApp = App::where('key', 'circle-contacts')->first();
$app->required = [$getContactsApp->id];
$app->save();
}
$this->callSilent('optimize:clear');
$this->artisanCommand(["migrate"]);
$this->artisanCommand(["optimize:clear"]);
$this->info('Circle Contacts App installed successfully.');
}
}
Empty file.
Empty file.
Loading

0 comments on commit 1f807a4

Please sign in to comment.