This commit is contained in:
profstyle1@gmail.com 2019-10-23 17:23:34 +03:00
commit a49d3aec61
11 changed files with 111 additions and 54 deletions

View File

@ -2,7 +2,9 @@
OpenClassify is the extensible and most advanced open source classified app build with Laravel and Pyrocms.
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/openclassify/openclassify/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/openclassify/openclassify/?branch=master)
[![Build Status](https://scrutinizer-ci.com/g/openclassify/openclassify/badges/build.png?b=master)](https://scrutinizer-ci.com/g/openclassify/openclassify/build-status/master)
[![Code Intelligence Status](https://scrutinizer-ci.com/g/openclassify/openclassify/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence)
# Installation

View File

@ -217,7 +217,8 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
break;
}
} else {
$query = $query->orderBy('created_at', 'desc');
$query = $query->orderBy('advs_advs.created_at', 'desc');
$query = $query->select('advs_advs.*', 'advs_advs_translations.name as name', 'advs_advs_translations.advs_desc as advs_desc');
}

View File

@ -6,7 +6,7 @@ use Anomaly\Streams\Platform\Application\Application;
use Anomaly\Streams\Platform\Entry\Contract\EntryInterface;
use Anomaly\Streams\Platform\Model\Advs\AdvsAdvsEntryModel;
use Anomaly\Streams\Platform\Model\Cats\CatsCategoryEntryModel;
use Anomaly\Streams\Platform\Model\Users\UsersUsersEntryModel;
use Anomaly\UsersModule\User\UserModel;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Http\Request;
use Visiosoft\AdvsModule\Adv\Table\Filter\CategoryFilterQuery;
@ -72,9 +72,8 @@ class AdvsController extends AdminController
]
]);
if($this->model->is_enabled('recommendedads'))
{
$table->addButton('add_recommended',[
if ($this->model->is_enabled('recommendedads')) {
$table->addButton('add_recommended', [
'type' => 'default',
'icon' => 'fa fa-gg',
'text' => 'Add Recommended',
@ -96,15 +95,17 @@ class AdvsController extends AdminController
'class' => 'advs-country',
],
'created_by' => [
'value' => function (EntryInterface $entry) {
$user = UsersUsersEntryModel::query()->where('users_users.id', $entry->created_by_id)->first();
return $user->first_name . " " . $user->last_name;
'value' => function (EntryInterface $entry, UserModel $userModel) {
$user = $userModel->find($entry->created_by_id);
if (!is_null($user))
return $user->first_name . " " . $user->last_name;
}
],
'category' => [
'value' => function (EntryInterface $entry) {
$category = CategoryModel::query()->where('cats_category.id', $entry->cat1)->first();
return $category->name;
'value' => function (EntryInterface $entry, CategoryModel $categoryModel) {
$category = $categoryModel->getCat($entry->cat1);
if (!is_null($category))
return $category->name;
}
],
]);

View File

@ -14,32 +14,34 @@ class AjaxController extends PublicController
public function locations(Request $request)
{
$datas = [];
if($request->level == 1){
if ($request->level == 1) {
$datas = CityModel::where('parent_country_id', $request->cat)->get();
}else if($request->level == 2){
} else if ($request->level == 2) {
$datas = DistrictModel::where('parent_city_id', $request->cat)->get();
}else if($request->level == 3){
} else if ($request->level == 3) {
$datas = NeighborhoodModel::where('parent_district_id', $request->cat)->get();
}else if($request->level == 4){
} else if ($request->level == 4) {
$datas = VillageModel::where('parent_neighborhood_id', $request->cat)->get();
}
return response()->json($datas);
}
public function categories(Request $request)
{
$datas = [];
if($request->level == 0){
if ($request->level == 0) {
$datas = CategoryModel::whereNull('parent_category_id')->get();
}else{
} else {
$datas = CategoryModel::where('parent_category_id', $request->cat)->get();
}
return response()->json($datas);
}
public function keySearch(Request $request)
{
$datas = [];
$catModel = new CategoryModel();
$datas['category'] = $catModel->searchKeyword($request->q);
$datas['category'] = $catModel->searchKeyword($request->q, $request->selected);
return response()->json($datas);
}

View File

@ -12,7 +12,7 @@ class CategoryModel extends CatsCategoryEntryModel implements CategoryInterface
return CategoryModel::query()->where('cats_category.id', $id)->first();
}
public function getParentCats($id, $type = null, $subCatDeepCount = 5)
public function getParentCats($id, $type = null, $subCatDeepCount = 7)
{
$cat = $this->getCat($id);
$catNames = array();
@ -21,9 +21,9 @@ class CategoryModel extends CatsCategoryEntryModel implements CategoryInterface
$cat_ids[] = $cat->id;
$subCat = $cat->parent_category_id;
if ($subCat != null) {
for ($i = 0; $i < $subCatDeepCount; $i++) {
for ($i = 0; $i < 7; $i++) {
$parCat = $this->getCat($subCat);
if ($parCat == null) {
if ($parCat->parent_category_id == "") {
break;
}
$catNames[] = $parCat->name;
@ -43,7 +43,8 @@ class CategoryModel extends CatsCategoryEntryModel implements CategoryInterface
public function getCatLevel($id)
{
return count($this->getParentCats($id));
//count parent and itself
return count($this->getParentCats($id))+1;
}
public function getSubCategories($id, $get = null)
@ -77,16 +78,27 @@ class CategoryModel extends CatsCategoryEntryModel implements CategoryInterface
return true;
}
public function searchKeyword($keyword)
public function searchKeyword($keyword, $selected = null)
{
$data = [];
$cats = DB::table('cats_category_translations')
->select('cats_category.id', 'cats_category_translations.name', 'cats_category.parent_category_id')
->where('name', 'like', $keyword . '%')
->join('cats_category', 'cats_category_translations.entry_id', '=', 'cats_category.id')
->orderBy('cats_category_translations.id', 'DESC')
->get();
$cats = DB::table('cats_category');
if ($selected != null) {
if (strpos($selected, "-") !== false) {
$selected = explode('-', $selected);
$cats = $cats->whereNotIn('cats_category.id', $selected);
} else {
$cats = $cats->where('cats_category.id', '!=', $selected);
}
}
$cats = $cats->where('name', 'like', $keyword . '%');
$cats = $cats->leftJoin('cats_category_translations', function ($join) {
$join->on('cats_category.id', '=', 'cats_category_translations.entry_id');
$join->where('cats_category_translations.locale', '=', Request()->session()->get('_locale'));
});
$cats = $cats->select('cats_category.*','cats_category_translations.name as name');
$cats = $cats->orderBy('id', 'DESC')
->get();
foreach ($cats as $cat) {
$link = '';
$parents = $this->getParentCats($cat->id, null, 2);

View File

@ -23,12 +23,14 @@ class CategoryRepository extends EntryRepository implements CategoryRepositoryIn
{
$this->model = $model;
}
public function findById($id)
{
return $this->model->orderBy('created_at', 'DESC')->where('cats_category.id', $id)->first();
}
public function mainCats(){
public function mainCats()
{
return $this->model->where('parent_category_id', null)->where('deleted_at', null)->get();
}
@ -51,8 +53,14 @@ class CategoryRepository extends EntryRepository implements CategoryRepositoryIn
{
return CatsCategoryEntryModel::query()->where('cats_category.id', $id)->first();
}
public function findBySlug($slug)
{
return $this->model->orderBy('created_at', 'DESC')->where('slug', $slug)->first();
}
public function getCategories()
{
return $this->model->get();
}
}

View File

@ -17,4 +17,6 @@ interface CategoryRepositoryInterface extends EntryRepositoryInterface
public function getSingleCat($id);
public function findBySlug($slug);
public function getCategories();
}

View File

@ -39,6 +39,7 @@ class CategoryController extends AdminController
if ($this->request->action == "save") {
$all = $this->request->all();
$id = $all['parent_category'];
$parent_id = $all['parent_category'];
$k = 1;
for ($i = 0; $i < $k; $i++) {
$cat1 = CategoryModel::query()->where('cats_category.id', $id)->first();
@ -57,6 +58,11 @@ class CategoryController extends AdminController
if ($form->hasFormErrors()) {
return $this->redirect->to('/admin/cats/create');
}
if($parent_id != "")
{
return $this->redirect->to('/admin/cats?cat='.$parent_id);
}
return $this->redirect->to('/admin/cats');
} else {
$form->setFields(['name']);

View File

@ -9,7 +9,7 @@
class="img-responsive">
{% endif %}
<font>{{ main_category.name }}</font>
<span>Konut, İşyeri, Arsa, Projeler, Bina, Devremülk, Turistik Tesis</span></a>
{# <span>Konut, İşyeri, Arsa, Projeler, Bina, Devremülk, Turistik Tesis</span></a>#}
</li>
{% endfor %}
</ul>

View File

@ -8,6 +8,7 @@ use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
use Anomaly\UsersModule\User\Event\UserWasLoggedIn;
use Anomaly\UsersModule\User\User;
use Anomaly\UsersModule\User\UserPassword;
use http\Env\Response;
use Visiosoft\AdvsModule\Adv\AdvModel;
use Visiosoft\AdvsModule\Http\Controller\AdvsController;
use Visiosoft\CartsModule\Saleitem\Command\ProcessSaleitem;
@ -102,12 +103,10 @@ class UserAuthenticator
if ($response = $this->authenticate($credentials)) {
if ($response instanceof UserInterface) {
$this->login($response, $remember);
if(isset($_COOKIE['cart']))
{
foreach ($_COOKIE['cart'] as $adv => $quantity)
{
if (isset($_COOKIE['cart'])) {
foreach ($_COOKIE['cart'] as $adv => $quantity) {
$advs = new AdvsController();
$advs->advAddCart($adv,$quantity);
$advs->advAddCart($adv, $quantity);
setcookie("cart[" . $adv . "]", null, -1, '/');
}
}
@ -162,6 +161,17 @@ class UserAuthenticator
public function registerAjax(UserRepositoryInterface $users, Request $request)
{
$required_field = ['first_name', 'last_name', 'email', 'subdomain'];
foreach ($required_field as $field) {
if (!isset($request->$field) or $request->$field == "") {
return $this->responseJSON('error', $field . ' field is required!');
die;
}
}
$siteModel = new SiteModel();
$userPlan = new UserModel();
$all = $request->all();
$email = explode('@', $all['email']);
@ -171,41 +181,54 @@ class UserAuthenticator
$all['activated'] = 1; //Activated User
$all['str_id'] = str_random(24); //User random key
$planParams['plan'] = 24;
if(isset($all['plan_id']))
{
//find plan id for request
if (isset($all['plan_id'])) {
$planParams['plan'] = $all['plan_id'];
unset($all['plan_id']);//Demo Plan id
}
if (User::withTrashed()->where('email',$all['email'])->first() or User::withTrashed()->where('username',$all['username'])->first()) {
return response()->json(['status' => 'error', 'message' => 'This Username or Email Registered!']);
//find subdomain in allready exit
$isSubdomain = $siteModel->getSitesBySubdomain($all['subdomain']);
if ($this->advModel->is_enabled('cloudsite') and !is_null($isSubdomain)) {
return $this->responseJSON('error', 'This subdomain is already exists!');
}
if (User::withTrashed()->where('email', $all['email'])->first() or User::withTrashed()->where('username', $all['username'])->first()) {
return $this->responseJSON('error', 'This Username or Email Registered!');
}
//create random password
$opassword = str_random(8);
$user = User::query()->create($all);
$user_params = $all;
unset($user_params['subdomain']);
//create user
$user = User::query()->create($user_params);
$user->setAttribute('password', $opassword);
$users->save($user);
$all['password'] = $opassword; //Register Password Original
if(!isset($all['subdomain']))
{
$all['subdomain'] = $all['username'];
}
$all['user'] = $user;
$planParams['user'] = $user->id; //Register User id
$planParams['name'] = $all['subdomain']; //Subscription Saved Name
if($this->advModel->is_enabled('cloudsite'))
{
$userPlan = new UserModel();
if ($this->advModel->is_enabled('cloudsite')) {
$plan = $userPlan->addPlanAjaxUser($planParams);
$siteModel = new SiteModel();
$siteModel->createSite($all['subdomain'], $user->id, $opassword, $plan->id); //Create Site
$this->events->dispatch(new CreateSite($all, $this->settings));
//$this->events->dispatch(new CreateSite($all, $this->settings));
}
return response()->json(['status' => 'success', 'message' => 'Thank you for Registering!']);
return $this->responseJSON('success', 'Thank you for Registering!');
}
public function responseJSON($type, $message)
{
return response()->json(['status' => $type, 'message' => $message]);
}
}

View File

@ -72,7 +72,7 @@ class ProfileModuleSeeder extends Seeder
'slug' => 'favicon',
'disk' => $disk,
'allowed_types' => [
'ico'
'ico','png'
],
]
);