-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update messages view / add realtime / add circle notes / add circle docs
- Loading branch information
Showing
151 changed files
with
4,770 additions
and
101 deletions.
There are no files selected for viewing
Binary file not shown.
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
Empty file.
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,63 @@ | ||
<?php | ||
|
||
namespace Modules\CircleDocs\App\Console; | ||
|
||
use Illuminate\Console\Command; | ||
use Modules\CircleApps\App\Models\App; | ||
use TomatoPHP\ConsoleHelpers\Traits\RunCommand; | ||
|
||
class CircleDocsInstall extends Command | ||
{ | ||
use RunCommand; | ||
|
||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'circle-docs: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-docs')->first(); | ||
if(!$app){ | ||
$app = new App(); | ||
$app->key = 'circle-docs'; | ||
$app->name = 'Circle Docs'; | ||
$app->description = 'Create and share, search in your docs using markdown editor and GitHub integration'; | ||
$app->is_active = true; | ||
$app->is_free = true; | ||
$app->status = "active"; | ||
$app->homepage = "https://www.github.com/tomatophp/circle-docs"; | ||
$app->github = "https://www.github.com/tomatophp/circle-docs"; | ||
$app->docs = "https://www.github.com/tomatophp/circle-docs"; | ||
$app->privacy = "https://www.github.com/tomatophp/circle-docs"; | ||
$app->faq = "https://www.github.com/tomatophp/circle-docs"; | ||
$app->email = "[email protected]"; | ||
$app->save(); | ||
} | ||
$this->callSilent('optimize:clear'); | ||
$this->artisanCommand(["migrate"]); | ||
$this->artisanCommand(["optimize:clear"]); | ||
$this->info('Circle Contacts App installed successfully.'); | ||
} | ||
} |
Empty file.
Empty file.
81 changes: 81 additions & 0 deletions
81
Modules/CircleDocs/App/Http/Controllers/CircleDocsController.php
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,81 @@ | ||
<?php | ||
|
||
namespace Modules\CircleDocs\App\Http\Controllers; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Models\Account; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Response; | ||
use Modules\CircleDocs\App\Models\CircleXoDoc; | ||
|
||
class CircleDocsController extends Controller | ||
{ | ||
/** | ||
* Display a listing of the resource. | ||
*/ | ||
public function index(Request $request) | ||
{ | ||
$query = CircleXoDoc::query(); | ||
$query->where('is_public', true); | ||
if($request->has('search') && $request->input('search') != ''){ | ||
$query->where('name', 'like', '%'.$request->input('search').'%')->orWhere('package', 'like', '%'.$request->input('search').'%'); | ||
} | ||
$query->where('is_public', true); | ||
$query = $query->paginate(12); | ||
|
||
return view('circle-docs::index', [ | ||
'docs' => $query | ||
]); | ||
} | ||
|
||
public function profile($username) | ||
{ | ||
$account = Account::where('username', $username)->firstOrFail(); | ||
if($account){ | ||
$query = CircleXoDoc::query(); | ||
$query->where('account_id', $account->id); | ||
$query->where('is_public', true); | ||
$query = $query->paginate(12); | ||
|
||
return view('circle-docs::profile', [ | ||
'docs' => $query, | ||
'account' => $account | ||
]); | ||
} | ||
} | ||
|
||
/** | ||
* Show the specified resource. | ||
*/ | ||
public function show($username, $slug) | ||
{ | ||
$account = Account::where('username', $username)->firstOrFail(); | ||
if($account){ | ||
$doc = CircleXoDoc::where('package', $slug)->where('account_id', $account->id)->firstOrFail(); | ||
return view('circle-docs::show', [ | ||
'doc' => $doc, | ||
'account' => $account | ||
]); | ||
} | ||
} | ||
|
||
/** | ||
* Show the specified resource. | ||
*/ | ||
public function page($username, $slug, $page) | ||
{ | ||
$account = Account::where('username', $username)->firstOrFail(); | ||
if($account){ | ||
$doc = CircleXoDoc::where('package', $slug)->where('account_id', $account->id)->firstOrFail(); | ||
if($doc){ | ||
$page = $doc->pages()->where('slug', $page)->firstOrFail(); | ||
return view('circle-docs::show', [ | ||
'doc' => $doc, | ||
'currentPage' => $page, | ||
'account' => $account | ||
]); | ||
} | ||
} | ||
} | ||
} |
207 changes: 207 additions & 0 deletions
207
Modules/CircleDocs/App/Http/Controllers/CircleXoDocController.php
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,207 @@ | ||
<?php | ||
|
||
namespace Modules\CircleDocs\App\Http\Controllers; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Http\RedirectResponse; | ||
use Illuminate\Http\JsonResponse; | ||
use Illuminate\Http\Request; | ||
use Illuminate\View\View; | ||
use ProtoneMedia\Splade\Facades\Toast; | ||
use TomatoPHP\TomatoAdmin\Facade\Tomato; | ||
|
||
class CircleXoDocController extends Controller | ||
{ | ||
public string $model; | ||
|
||
public function __construct() | ||
{ | ||
$this->model = \Modules\CircleDocs\App\Models\CircleXoDoc::class; | ||
} | ||
|
||
public function like(Request $request) | ||
{ | ||
$request->validate([ | ||
"type"=> "required|in:page,doc" | ||
]); | ||
|
||
|
||
if($request->get('type') === 'page') | ||
{ | ||
$request->validate([ | ||
"id" => "required|exists:circle_xo_docs_pages,id", | ||
]); | ||
} | ||
else if($request->get('type') === 'doc') | ||
{ | ||
$request->validate([ | ||
"id" => "required|exists:circle_xo_docs,id", | ||
]); | ||
} | ||
|
||
$model = $request->get('type') === 'doc' ? \Modules\CircleDocs\App\Models\CircleXoDoc::find($request->id) : \Modules\CircleDocs\App\Models\CircleXoDocsPage::find($request->id); | ||
auth('accounts')->user()->hasLiked($model) ? auth('accounts')->user()->unlike($model) : auth('accounts')->user()->like($model); | ||
|
||
$request->get('type') === 'doc' ? $account = $model->account : $account = $model->doc->account; | ||
if($account->id !== auth('accounts')->user()->id) { | ||
$account->notifyDB( | ||
message: __(auth('accounts')->user()->username . " " . __('is like your docs page') . ' ' . $request->get('type') === 'doc' ? $model->name : $model->title), | ||
title: __('New Like'), | ||
url: url(auth('accounts')->user()->username) | ||
); | ||
} | ||
|
||
Toast::success(__('Liked successfully'))->autoDismiss(2); | ||
return back(); | ||
|
||
} | ||
|
||
/** | ||
* @param Request $request | ||
* @return View|JsonResponse | ||
*/ | ||
public function index(Request $request): View|JsonResponse | ||
{ | ||
return Tomato::index( | ||
request: $request, | ||
model: $this->model, | ||
view: 'circle-docs::docs.index', | ||
table: \Modules\CircleDocs\App\Tables\CircleXoDocTable::class | ||
); | ||
} | ||
|
||
/** | ||
* @param Request $request | ||
* @return JsonResponse | ||
*/ | ||
public function api(Request $request): JsonResponse | ||
{ | ||
return Tomato::json( | ||
request: $request, | ||
model: \Modules\CircleDocs\App\Models\CircleXoDoc::class, | ||
); | ||
} | ||
|
||
/** | ||
* @return View | ||
*/ | ||
public function create(): View | ||
{ | ||
return Tomato::create( | ||
view: 'circle-docs::docs.create', | ||
); | ||
} | ||
|
||
/** | ||
* @param \Modules\CircleDocs\App\Http\Requests\CircleXoDoc\CircleXoDocStoreRequest $request | ||
* @return RedirectResponse|JsonResponse | ||
*/ | ||
public function store(\Modules\CircleDocs\App\Http\Requests\CircleXoDoc\CircleXoDocStoreRequest $request): RedirectResponse|JsonResponse | ||
{ | ||
$request->merge([ | ||
'account_id' => auth('accounts')->user()->id, | ||
]); | ||
|
||
$response = Tomato::store( | ||
request: $request, | ||
model: \Modules\CircleDocs\App\Models\CircleXoDoc::class, | ||
message: __('Doc saved successfully'), | ||
redirect: 'profile.docs.index', | ||
hasMedia: true, | ||
collection: [ | ||
'icon' => false, | ||
'cover' => false, | ||
] | ||
); | ||
|
||
if($response instanceof JsonResponse){ | ||
return $response; | ||
} | ||
|
||
return $response->redirect; | ||
} | ||
|
||
/** | ||
* @param \Modules\CircleDocs\App\Models\CircleXoDoc $model | ||
* @return View|JsonResponse|RedirectResponse | ||
*/ | ||
public function show(\Modules\CircleDocs\App\Models\CircleXoDoc $model, Request $request): View|JsonResponse|RedirectResponse | ||
{ | ||
return Tomato::get( | ||
model: $model, | ||
view: 'circle-docs::docs.show', | ||
hasMedia: true, | ||
collection: [ | ||
'icon' => false, | ||
'cover' => false, | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* @param \Modules\CircleDocs\App\Models\CircleXoDoc $model | ||
* @return View | ||
*/ | ||
public function edit(\Modules\CircleDocs\App\Models\CircleXoDoc $model): View | ||
{ | ||
return Tomato::get( | ||
model: $model, | ||
view: 'circle-docs::docs.edit', | ||
hasMedia: true, | ||
collection: [ | ||
'icon' => false, | ||
'cover' => false, | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* @param \Modules\CircleDocs\App\Http\Requests\CircleXoDoc\CircleXoDocUpdateRequest $request | ||
* @param \Modules\CircleDocs\App\Models\CircleXoDoc $model | ||
* @return RedirectResponse|JsonResponse | ||
*/ | ||
public function update(\Modules\CircleDocs\App\Http\Requests\CircleXoDoc\CircleXoDocUpdateRequest $request, \Modules\CircleDocs\App\Models\CircleXoDoc $model): RedirectResponse|JsonResponse | ||
{ | ||
$response = Tomato::update( | ||
request: $request, | ||
model: $model, | ||
message: __('Doc updated successfully'), | ||
redirect: 'profile.docs.index', | ||
hasMedia: true, | ||
collection: [ | ||
'icon' => false, | ||
'cover' => false, | ||
] | ||
); | ||
|
||
if($response instanceof JsonResponse){ | ||
return $response; | ||
} | ||
|
||
return $response->redirect; | ||
} | ||
|
||
/** | ||
* @param \Modules\CircleDocs\App\Models\CircleXoDoc $model | ||
* @return RedirectResponse|JsonResponse | ||
*/ | ||
public function destroy(\Modules\CircleDocs\App\Models\CircleXoDoc $model): RedirectResponse|JsonResponse | ||
{ | ||
$response = Tomato::destroy( | ||
model: $model, | ||
message: __('Doc deleted successfully'), | ||
redirect: 'profile.docs.index', | ||
hasMedia: true, | ||
collection: [ | ||
'icon' => false, | ||
'cover' => false, | ||
] | ||
); | ||
|
||
if($response instanceof JsonResponse){ | ||
return $response; | ||
} | ||
|
||
return $response->redirect; | ||
} | ||
} |
Oops, something went wrong.