mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
Merge pull request #383 from openclassify/dia
#996 Merge profile and users module
This commit is contained in:
commit
bad39e4280
@ -26,7 +26,6 @@
|
||||
<!--detail-ad -->
|
||||
<div class="section slider mb-4">
|
||||
<div class="row">
|
||||
|
||||
{% include "visiosoft.module.advs::ad-detail/partials/slider" %}
|
||||
<div class="col-md-5">
|
||||
{% if setting_value('visiosoft.theme.base::ad_details') %}
|
||||
|
||||
@ -4,7 +4,6 @@ use Anomaly\Streams\Platform\Entry\EntryPresenter;
|
||||
use Anomaly\Streams\Platform\Model\Cloudinary\CloudinaryVideoEntryModel;
|
||||
use Anomaly\Streams\Platform\Model\Users\UsersUsersEntryModel;
|
||||
use Illuminate\Routing\Route;
|
||||
use Visiosoft\ProfileModule\Profile\ProfileModel;
|
||||
|
||||
class AdvPresenter extends EntryPresenter
|
||||
{
|
||||
@ -46,11 +45,9 @@ class AdvPresenter extends EntryPresenter
|
||||
|
||||
public function isCorporate()
|
||||
{
|
||||
$user_id = $this->getObject()->created_by_id;
|
||||
$profile = new ProfileModel();
|
||||
$profile = $profile->getProfile($user_id)->first();
|
||||
if ($profile != null) {
|
||||
return $profile->register_type;
|
||||
$user_id = $this->getObject()->created_by;
|
||||
if ($user_id->register_type != null) {
|
||||
return $user_id->register_type;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Cookie;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Visiosoft\LocationModule\City\CityRepository;
|
||||
use Visiosoft\StoreModule\User\Contract\UserRepositoryInterface;
|
||||
use function PMA\Util\get;
|
||||
use Sunra\PhpSimple\HtmlDomParser;
|
||||
use Visiosoft\AdvsModule\Adv\AdvModel;
|
||||
@ -44,8 +45,6 @@ use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface;
|
||||
use Visiosoft\LocationModule\Country\Contract\CountryRepositoryInterface;
|
||||
use Anomaly\Streams\Platform\Message\MessageBag;
|
||||
use Visiosoft\PackagesModule\Package\PackageModel;
|
||||
use Visiosoft\ProfileModule\Profile\Contract\ProfileRepositoryInterface;
|
||||
use Visiosoft\ProfileModule\Profile\ProfileModel;
|
||||
|
||||
use Anomaly\Streams\Platform\Model\Customfields\CustomfieldsCustomFieldsEntryModel;
|
||||
use Anomaly\Streams\Platform\Model\Customfields\CustomfieldsCustomFieldAdvsEntryModel;
|
||||
@ -57,6 +56,8 @@ use Visiosoft\StoreModule\Ad\AdModel;
|
||||
|
||||
class AdvsController extends PublicController
|
||||
{
|
||||
private $userRepository;
|
||||
|
||||
private $adv_model;
|
||||
private $adv_repository;
|
||||
|
||||
@ -71,9 +72,6 @@ class AdvsController extends PublicController
|
||||
|
||||
private $village_model;
|
||||
|
||||
private $profile_model;
|
||||
private $profile_repository;
|
||||
|
||||
private $category_model;
|
||||
private $category_repository;
|
||||
|
||||
@ -82,6 +80,8 @@ class AdvsController extends PublicController
|
||||
private $event;
|
||||
|
||||
public function __construct(
|
||||
UserRepositoryInterface $userRepository,
|
||||
|
||||
AdvModel $advModel,
|
||||
AdvRepositoryInterface $advRepository,
|
||||
|
||||
@ -96,9 +96,6 @@ class AdvsController extends PublicController
|
||||
|
||||
VillageModel $village_model,
|
||||
|
||||
ProfileModel $profile_model,
|
||||
ProfileRepositoryInterface $profile_repository,
|
||||
|
||||
CategoryModel $categoryModel,
|
||||
CategoryRepositoryInterface $category_repository,
|
||||
|
||||
@ -109,6 +106,8 @@ class AdvsController extends PublicController
|
||||
Request $request
|
||||
)
|
||||
{
|
||||
$this->userRepository = $userRepository;
|
||||
|
||||
$this->adv_model = $advModel;
|
||||
$this->adv_repository = $advRepository;
|
||||
|
||||
@ -123,10 +122,6 @@ class AdvsController extends PublicController
|
||||
|
||||
$this->village_model = $village_model;
|
||||
|
||||
|
||||
$this->profile_model = $profile_model;
|
||||
$this->profile_repository = $profile_repository;
|
||||
|
||||
$this->category_model = $categoryModel;
|
||||
$this->category_repository = $category_repository;
|
||||
|
||||
@ -262,8 +257,7 @@ class AdvsController extends PublicController
|
||||
}
|
||||
|
||||
if (!empty($param['user'])) {
|
||||
$user = $this->profile_repository->getUser($param['user']);
|
||||
$userProfile = $this->profile_repository->getProfile($user->id);
|
||||
$user = $this->userRepository->find($param['user']);
|
||||
}
|
||||
|
||||
Cookie::queue(Cookie::make('last_search', $this->requestHttp->getRequestUri(), 84000));
|
||||
@ -271,7 +265,7 @@ class AdvsController extends PublicController
|
||||
$viewType = $this->requestHttp->cookie('viewType');
|
||||
|
||||
$compact = compact('advs', 'countries', 'mainCats', 'subCats', 'checkboxes', 'request', 'param',
|
||||
'user', 'userProfile', 'featured_advs', 'viewType', 'topfields', 'ranges', 'seenList', 'searchedCountry', 'radio');
|
||||
'user', 'featured_advs', 'viewType', 'topfields', 'ranges', 'seenList', 'searchedCountry', 'radio');
|
||||
|
||||
return $this->viewTypeBasedRedirect($viewType, $compact);
|
||||
}
|
||||
@ -352,9 +346,6 @@ class AdvsController extends PublicController
|
||||
}
|
||||
}
|
||||
|
||||
$profile = $this->profile_model->getProfile($adv->created_by_id)->first();
|
||||
|
||||
|
||||
if ($isCommentActive) {
|
||||
$CommentModel = new CommentModel();
|
||||
$comments = $CommentModel->getComments($adv->id)->get();
|
||||
@ -367,7 +358,7 @@ class AdvsController extends PublicController
|
||||
$this->template->set('meta_image', $adv->cover_photo);
|
||||
|
||||
if ($adv->created_by_id == isset(auth()->user()->id) OR $adv->status == "approved") {
|
||||
return $this->view->make('visiosoft.module.advs::ad-detail/detail', compact('adv', 'complaints', 'recommended_advs', 'categories', 'features', 'profile', 'comments', 'qrSRC'));
|
||||
return $this->view->make('visiosoft.module.advs::ad-detail/detail', compact('adv', 'complaints', 'recommended_advs', 'categories', 'features', 'comments', 'qrSRC'));
|
||||
} else {
|
||||
return back();
|
||||
}
|
||||
@ -789,14 +780,15 @@ class AdvsController extends PublicController
|
||||
return $this->view->make('theme::addons/anomaly/pages-module/page', compact('cats'));
|
||||
}
|
||||
|
||||
public function map(AdvRepositoryInterface $advRepository,
|
||||
CategoryRepositoryInterface $categories,
|
||||
CountryRepositoryInterface $countries,
|
||||
ProfileRepositoryInterface $profileRepository,
|
||||
Request $request)
|
||||
public function map(
|
||||
AdvRepositoryInterface $advRepository,
|
||||
CategoryRepositoryInterface $categories,
|
||||
CountryRepositoryInterface $countries,
|
||||
Request $request
|
||||
)
|
||||
{
|
||||
|
||||
return $this->index($advRepository, $categories, $countries, $profileRepository, $request, true);
|
||||
return $this->index($advRepository, $categories, $countries, $request, true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,88 @@
|
||||
new Promise(function (resolve, reject) {
|
||||
if (parseInt(default_country)) {
|
||||
getCities(parseInt(default_country));
|
||||
resolve(true);
|
||||
}
|
||||
}).then(function (resolve) {
|
||||
if (resolve) {
|
||||
if (parseInt(default_city)) {
|
||||
getDistricts(parseInt(default_city));
|
||||
$('select[name="city"]').val(default_city);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}).then(function (resolve) {
|
||||
if (resolve) {
|
||||
if (parseInt(default_district)) {
|
||||
getNeighborhoods(parseInt(default_district));
|
||||
$('select[name="district"]').val(default_district);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}).then(function (resolve) {
|
||||
if (resolve) {
|
||||
if (parseInt(default_neighborhood)) {
|
||||
$('select[name="neighborhood"]').val(default_neighborhood)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function getCities(country) {
|
||||
crud('id=' + country, '/ajax/getCities', 'POST', function (callback) {
|
||||
cities = callback;
|
||||
$('select[name="city"]').html("<option value=''>" + pick_option + "</option>");
|
||||
$.each(cities, function (index, value) {
|
||||
$('select[name="city"]').append("<option value='" + value.id + "'>" + value.name + "</option>");
|
||||
});
|
||||
$('select[name="district"]').html("<option value=''>" + pick_option + "</option>");
|
||||
$('select[name="neighborhood"]').html("<option value=''>" + pick_option + "</option>");
|
||||
$('select[name="village"]').html("<option value=''>" + pick_option + "</option>");
|
||||
})
|
||||
}
|
||||
|
||||
function getDistricts(city) {
|
||||
crud('id=' + city, '/ajax/getDistricts', 'POST', function (callback) {
|
||||
cities = callback;
|
||||
$('select[name="district"]').html("<option value=''>" + pick_option + "</option>");
|
||||
$.each(cities, function (index, value) {
|
||||
$('select[name="district"]').append("<option value='" + value.id + "'>" + value.name + "</option>");
|
||||
});
|
||||
$('select[name="neighborhood"]').html("<option value=''>" + pick_option + "</option>");
|
||||
$('select[name="village"]').html("<option value=''>" + pick_option + "</option>");
|
||||
})
|
||||
}
|
||||
|
||||
function getNeighborhoods(district) {
|
||||
crud('id=' + district, '/ajax/getNeighborhoods', 'POST', function (callback) {
|
||||
cities = callback;
|
||||
$('select[name="neighborhood"]').html("<option value=''>" + pick_option + "</option>");
|
||||
$.each(cities, function (index, value) {
|
||||
$('select[name="neighborhood"]').append("<option value='" + value.id + "'>" + value.name + "</option>");
|
||||
});
|
||||
$('select[name="village"]').html("<option value=''>" + pick_option + "</option>");
|
||||
})
|
||||
}
|
||||
|
||||
$(document).on('change', 'select[name="country"]', function () {
|
||||
getCities($(this).val());
|
||||
});
|
||||
|
||||
$(document).on('change', 'select[name="city"]', function () {
|
||||
getDistricts($(this).val())
|
||||
});
|
||||
|
||||
$(document).on('change', 'select[name="district"]', function () {
|
||||
getNeighborhoods($(this).val())
|
||||
});
|
||||
|
||||
function crud(params, url, type, callback) {
|
||||
$.ajax({
|
||||
type: type,
|
||||
data: params,
|
||||
async: false,
|
||||
url: url,
|
||||
success: function (response) {
|
||||
callback(response);
|
||||
},
|
||||
});
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
<ul class="nav nav-sections {{ stacked ? 'nav-stacked' }}">
|
||||
{% spaceless %}
|
||||
{% for slug, tab in tabs %}
|
||||
<li class="nav-item {{ loop.first ? ' active' }}">
|
||||
<a href="#tab-{{ form.options.prefix }}{{ tab.slug ?: slug }}" data-toggle="tab" class="nav-link">
|
||||
{{ tab.icon ? icon(tab.icon) }}
|
||||
{{ trans(tab.title) }}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% endspaceless %}
|
||||
</ul>
|
||||
|
||||
<div class="card-block card-body">
|
||||
{% for slug, tab in section.tabs %}
|
||||
<div class="tab__pane tab-pane {{ loop.first ? ' active' }}" id="tab-{{ form.options.prefix }}{{ tab.slug ?: slug }}">
|
||||
{% if tab.view %}
|
||||
{% include tab.view %}
|
||||
{% elseif tab.html %}
|
||||
{{ parse(tab.html)|raw }}
|
||||
{% elseif tab.rows %}
|
||||
{% include "streams::form/partials/rows" with {"rows": tab.rows} %}
|
||||
{% else %}
|
||||
{% if tab.fields is empty %}
|
||||
<div class="form-group ">
|
||||
{{ trans("streams::message.no_fields_available") }}
|
||||
</div>
|
||||
{% else %}
|
||||
|
||||
{% include "streams::form/partials/fields" with {"fields": tab.fields} %}
|
||||
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<script>
|
||||
var default_country = "{{ setting_value('visiosoft.module.location::default_country') }}"
|
||||
var default_city = "{{ setting_value('visiosoft.module.location::default_city') }}"
|
||||
var default_district = "{{ setting_value('visiosoft.module.location::default_district') }}"
|
||||
var default_neighborhood = "{{ setting_value('visiosoft.module.location::default_neighborhood') }}"
|
||||
var pick_option = "{{ trans('visiosoft.module.location::field.pick_option.name') }}"
|
||||
</script>
|
||||
{{ asset_add("scripts.js", "visiosoft.theme.defaultadmin::js/users/filterLocation.js") }}
|
||||
@ -36,4 +36,8 @@ class DefaultadminThemeServiceProvider extends AddonServiceProvider
|
||||
AbstractPaginator::$defaultView = 'visiosoft.theme.defaultadmin::pagination/bootstrap-4';
|
||||
AbstractPaginator::$defaultSimpleView = 'streams::pagination/simple-bootstrap-4';
|
||||
}
|
||||
|
||||
protected $overrides = [
|
||||
'streams::form/partials/tabs' => 'visiosoft.theme.defaultadmin::form/partials/tabs',
|
||||
];
|
||||
}
|
||||
|
||||
@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Anomaly\Streams\Platform\Database\Migration\Migration;
|
||||
|
||||
class VisiosoftModuleProfileCreateProfileStream extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* The stream definition.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $stream = [
|
||||
'slug' => 'profile',
|
||||
'title_column' => 'id',
|
||||
'translatable' => true,
|
||||
'trashable' => false,
|
||||
'searchable' => false,
|
||||
'sortable' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
* The stream assignments.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $assignments = [
|
||||
'user',
|
||||
'file',
|
||||
'email' => [
|
||||
'required' => true
|
||||
],
|
||||
'image',
|
||||
'country',
|
||||
'city',
|
||||
'district',
|
||||
'neighborhood',
|
||||
'village',
|
||||
'gsm_phone',
|
||||
'land_phone','office_phone','register_type',
|
||||
'identification_number',
|
||||
'notified_new_updates',
|
||||
'notified_about_ads',
|
||||
'receive_messages_email',
|
||||
'adv_listing_banner'
|
||||
];
|
||||
|
||||
}
|
||||
@ -4,28 +4,28 @@
|
||||
{% set showTheme = true %}
|
||||
{% endif %}
|
||||
{% if showTheme %}
|
||||
{% set profile = findUserProfile(params.adv.created_by_id) %}
|
||||
{% if profile.gsm_phone is not null %}
|
||||
{% set user = params.adv.created_by %}
|
||||
{% if user.gsm_phone is not null %}
|
||||
<div class="col-md-12 m-2 number-container">
|
||||
<button class="btn btn-secondary w-100">
|
||||
<i class="fas fa-mobile hide-number text-warning"></i>
|
||||
<span class="hide-number">{{ profile.gsm_phone }}</span>
|
||||
<span class="hide-number">{{ user.gsm_phone }}</span>
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if profile.office_phone is not empty %}
|
||||
{% if user.office_phone is not empty %}
|
||||
<div class="col-md-12 m-2 number-container">
|
||||
<button class="btn btn-secondary w-100">
|
||||
<i class="fas fa-headset hide-number text-warning"></i>
|
||||
<span class="hide-number">{{ profile.office_phone }}</span>
|
||||
<span class="hide-number">{{ user.office_phone }}</span>
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if profile.land_phone is not empty %}
|
||||
{% if user.land_phone is not empty %}
|
||||
<div class="col-md-12 m-2 number-container">
|
||||
<button class="btn btn-secondary w-100">
|
||||
<i class="fa fa-phone-square hide-number text-warning"></i>
|
||||
<span class="hide-number">{{ profile.land_phone }}</span>
|
||||
<span class="hide-number">{{ user.land_phone }}</span>
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{% extends "theme::layouts/default" %}
|
||||
{% block content %}
|
||||
|
||||
{% set profile_photo = profiles.file %}
|
||||
{% set profile_photo = user.file %}
|
||||
{% if profile_photo %}
|
||||
{% set profile_photo = file(profile_photo.id).url %}
|
||||
{% else %}
|
||||
@ -16,7 +16,6 @@
|
||||
<!-- User Profile Detail Section-->
|
||||
<div class="col-md-12 bg-dark">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-4 p-5">
|
||||
<div class="row">
|
||||
{% if setting_value('visiosoft.module.profile::upload_avatar') %}
|
||||
@ -26,11 +25,10 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="col-md-12 text-center align-middle text-white p-2 text-truncate">
|
||||
<h3>{{ user().first_name }} {{ user().last_name }}</h3>
|
||||
<h3>{{ user.first_name }} {{ user.last_name }}</h3>
|
||||
<small>{{ auth_user().last_login_at|date("d/m/Y H:i:s") }}</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -39,7 +37,6 @@
|
||||
|
||||
<!-- User Profile Form Section-->
|
||||
<div class="col-md-12 mt-5 bg-light profile-section">
|
||||
|
||||
<nav>
|
||||
<div class="nav nav-tabs nav-fill" id="nav-tab" role="tablist">
|
||||
<a class="nav-item nav-link active text-dark" id="nav-profile-tab" data-toggle="tab"
|
||||
@ -65,7 +62,7 @@
|
||||
<div class="tab-pane fade show active" id="nav-profile" role="tabpanel"
|
||||
aria-labelledby="nav-profile-tab">
|
||||
<div class="col-12">
|
||||
{% set userForm = form('userProfile').entry(auth_user().id).get() %}
|
||||
{% set userForm = form('userProfile').entry(user.id).get() %}
|
||||
{{ userForm.open()|raw }}
|
||||
<div class="form-group">
|
||||
<label class="control-label font-weight-bold">
|
||||
@ -83,7 +80,7 @@
|
||||
<label class="control-label font-weight-bold">
|
||||
{{ trans("visiosoft.module.profile::field.email.name") }}
|
||||
</label>
|
||||
<input value="{{ auth_user().email }}" type="text" disabled class="form-control">
|
||||
<input value="{{ user.email }}" type="text" disabled class="form-control">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
{{ userForm.actions|raw }}
|
||||
@ -95,7 +92,7 @@
|
||||
<div class="tab-pane fade" id="nav-details" role="tabpanel"
|
||||
aria-labelledby="nav-details-tab">
|
||||
<div class="col-12">
|
||||
{% set profileForm = form('profile').entry(profiles.id).get() %}
|
||||
{% set profileForm = form('profile').entry(user.id).get() %}
|
||||
|
||||
{{ profileForm.open()|raw }}
|
||||
|
||||
|
||||
@ -1,93 +0,0 @@
|
||||
<?php namespace Visiosoft\ProfileModule\Http\Controller\Admin;
|
||||
|
||||
use Anomaly\Streams\Platform\Entry\EntryModel;
|
||||
use Anomaly\Streams\Platform\Model\Users\UsersUsersEntryModel;
|
||||
use Anomaly\UsersModule\User\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Visiosoft\LocationModule\Country\CountryModel;
|
||||
use Visiosoft\ProfileModule\Profile\Form\ProfileFormBuilder;
|
||||
use Visiosoft\ProfileModule\Profile\ProfileModel;
|
||||
use Visiosoft\ProfileModule\Profile\Table\ProfileTableBuilder;
|
||||
use Anomaly\Streams\Platform\Http\Controller\AdminController;
|
||||
|
||||
class ProfileController extends AdminController
|
||||
{
|
||||
|
||||
/**
|
||||
* Display an index of existing entries.
|
||||
*
|
||||
* @param ProfileTableBuilder $table
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function index(ProfileTableBuilder $table)
|
||||
{
|
||||
$table->setColumns([
|
||||
'email' => [
|
||||
'value' => function (EntryModel $entry) {
|
||||
$user = User::query()->find($entry->id);
|
||||
if (!is_null($user))
|
||||
return $user->email;
|
||||
}
|
||||
],
|
||||
'gsm_phone'
|
||||
]);
|
||||
return $table->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new entry.
|
||||
*
|
||||
* @param ProfileFormBuilder $form
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function edit(ProfileFormBuilder $form, $id)
|
||||
{
|
||||
$users = UsersUsersEntryModel::find($id);
|
||||
$profiles = ProfileModel::query()->where('user_id', $id)->orderBy("id")->first();
|
||||
if ($profiles == null) {
|
||||
$newProfile = [];
|
||||
$newProfile ['user_id'] = $id;
|
||||
$newProfile ['country_id'] = null;
|
||||
ProfileModel::query()->create($newProfile);
|
||||
$profiles = ProfileModel::query()->where('user_id', $id)->orderBy("id")->first();
|
||||
}
|
||||
$country = CountryModel::all();
|
||||
return $this->view->make('visiosoft.module.profile::admin.profile.edit', compact('users', 'profiles', 'country', 'form'));
|
||||
}
|
||||
|
||||
public function update(ProfileFormBuilder $form, Request $request, $id)
|
||||
{
|
||||
$all = $request->all();
|
||||
if ($all['email'] == "" OR $all['username'] == "") {
|
||||
$error = [];
|
||||
if ($all['email'] == "") {
|
||||
$error[] = trans('visiosoft.module.profile::message.email');
|
||||
}
|
||||
if ($all['username'] == "") {
|
||||
$error[] = trans('visiosoft.module.profile::message.username');
|
||||
}
|
||||
return Redirect::back()->with('error', $error);
|
||||
}
|
||||
|
||||
$userModule = [];
|
||||
$userModule['email'] = $all['email'];
|
||||
$userModule['username'] = $all['username'];
|
||||
$userModule['display_name'] = $all['display_name'];
|
||||
$userModule['first_name'] = $all['first_name'];
|
||||
$userModule['last_name'] = $all['last_name'];
|
||||
$userModule['activated'] = $all['activated'];
|
||||
$userModule['enabled'] = $all['enabled'];
|
||||
UsersUsersEntryModel::query()->find($id)->update($userModule);
|
||||
foreach ($userModule as $key => $val) {
|
||||
unset($all[$key]);
|
||||
}
|
||||
$all['file_id'] = $all['file'];
|
||||
unset($all['file']);
|
||||
unset($all['_token'], $all['action']);
|
||||
ProfileModel::query()->where('user_id', $id)->update($all);
|
||||
$message = [];
|
||||
$message[] = trans('visiosoft.module.profile::message.success_update');
|
||||
return redirect('admin/profile')->with('success', $message);
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,7 @@ use Anomaly\Streams\Platform\Model\Options\OptionsAdvertisementEntryModel;
|
||||
use Anomaly\Streams\Platform\Model\Profile\ProfileAdressEntryModel;
|
||||
use Anomaly\Streams\Platform\Model\Users\UsersUsersEntryModel;
|
||||
use Anomaly\UsersModule\User\Contract\UserInterface;
|
||||
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
|
||||
use Anomaly\UsersModule\User\Password\Command\StartPasswordReset;
|
||||
use Anomaly\UsersModule\User\UserPassword;
|
||||
use Illuminate\Http\Request;
|
||||
@ -41,18 +42,18 @@ use Visiosoft\PackagesModule\User\UserModel;
|
||||
use Visiosoft\ProfileModule\Adress\AdressModel;
|
||||
use Visiosoft\ProfileModule\Adress\Contract\AdressRepositoryInterface;
|
||||
use Visiosoft\ProfileModule\Adress\Form\AdressFormBuilder;
|
||||
use Visiosoft\ProfileModule\Profile\Contract\ProfileRepositoryInterface;
|
||||
use Visiosoft\ProfileModule\Profile\Form\ProfileFormBuilder;
|
||||
use Visiosoft\ProfileModule\Profile\ProfileModel;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
|
||||
class MyProfileController extends PublicController
|
||||
{
|
||||
|
||||
private $adressRepository;
|
||||
private $userRepository;
|
||||
|
||||
public function __construct(AdressRepositoryInterface $adressRepository)
|
||||
public function __construct(
|
||||
AdressRepositoryInterface $adressRepository,
|
||||
UserRepositoryInterface $userRepository
|
||||
)
|
||||
{
|
||||
parent::__construct();
|
||||
if (!Auth::user()) {
|
||||
@ -60,6 +61,7 @@ class MyProfileController extends PublicController
|
||||
}
|
||||
|
||||
$this->adressRepository = $adressRepository;
|
||||
$this->userRepository = $userRepository;
|
||||
}
|
||||
|
||||
protected $user;
|
||||
@ -69,28 +71,15 @@ class MyProfileController extends PublicController
|
||||
//clear empty ads
|
||||
$advRepository->delete_empty_advs();
|
||||
|
||||
$menu_fields = array();
|
||||
$advs_count = new AdvModel();
|
||||
$advs_count = count($advs_count->myAdvsByUser()->get());
|
||||
|
||||
$profileModel = new ProfileModel();
|
||||
|
||||
$users = UsersUsersEntryModel::find(Auth::id());
|
||||
$profiles = $profileModel->getProfile(Auth::id())->orderBy("id")->first();
|
||||
|
||||
if ($profiles == null) {
|
||||
$newProfile = [];
|
||||
$newProfile ['user_id'] = Auth::id();
|
||||
|
||||
$profileModel->getProfile()->create($newProfile);
|
||||
|
||||
$profiles = $profileModel->getProfile(Auth::id())->orderBy("id")->first();
|
||||
}
|
||||
$user = $this->userRepository->find(Auth::id());
|
||||
|
||||
$country = CountryModel::all();
|
||||
return $this->view->make('visiosoft.module.profile::profile.detail', compact('users', 'profiles',
|
||||
'country', 'form', 'my_packages', 'menu_fields', 'myMessages', 'message_count', 'myPurchase',
|
||||
'mySales', 'advs_count', 'fav_count', 'userbalance', 'balancespackage'));
|
||||
|
||||
return $this->view->make('visiosoft.module.profile::profile.detail',
|
||||
compact('user','country', 'form', 'advs_count'));
|
||||
}
|
||||
|
||||
|
||||
@ -324,8 +313,7 @@ class MyProfileController extends PublicController
|
||||
{
|
||||
$all = $request->all();
|
||||
unset($all['_']);
|
||||
$profileModel = new ProfileModel();
|
||||
$status = $profileModel->getProfile(Auth::id())->update($all);
|
||||
$status = $this->userRepository->newQuery()->where('id', Auth::id())->update($all);
|
||||
return response()->json($status);
|
||||
|
||||
}
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
<?php namespace Visiosoft\ProfileModule\Profile\Command;
|
||||
|
||||
use Visiosoft\ProfileModule\Profile\Contract\ProfileRepositoryInterface;
|
||||
|
||||
class FindUserProfile
|
||||
{
|
||||
|
||||
/**
|
||||
* @var $id
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* GetProduct constructor.
|
||||
* @param $id
|
||||
*/
|
||||
public function __construct($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ProfileRepositoryInterface $profileRepository
|
||||
* @return |null
|
||||
*/
|
||||
public function handle(ProfileRepositoryInterface $profileRepository)
|
||||
{
|
||||
if ($this->id) {
|
||||
return $profileRepository->findByUserID($this->id);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
<?php namespace Visiosoft\ProfileModule\Profile\Contract;
|
||||
|
||||
use Anomaly\Streams\Platform\Entry\Contract\EntryInterface;
|
||||
|
||||
interface ProfileInterface extends EntryInterface
|
||||
{
|
||||
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
<?php namespace Visiosoft\ProfileModule\Profile\Contract;
|
||||
|
||||
use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface;
|
||||
|
||||
interface ProfileRepositoryInterface extends EntryRepositoryInterface
|
||||
{
|
||||
public function getUser($id);
|
||||
|
||||
public function getProfile($id);
|
||||
|
||||
public function validPasswordByEmail($email);
|
||||
|
||||
public function validPasswordByUsername($username);
|
||||
|
||||
public function updateUserField($fields);
|
||||
|
||||
public function changePassword($fields, $password);
|
||||
|
||||
public function findByUserID($id);
|
||||
|
||||
public function CheckPhoneNumber($phoneNumber);
|
||||
|
||||
public function findPhoneNumber($phone_number);
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
<?php namespace Visiosoft\ProfileModule\Profile\Event;
|
||||
|
||||
|
||||
class SiteStatusControl
|
||||
{
|
||||
public function __construct($request,$settings)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
public function getRequest()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
<?php namespace Visiosoft\ProfileModule\Profile\Handler;
|
||||
|
||||
use Anomaly\SelectFieldType\SelectFieldType;
|
||||
|
||||
class registerType
|
||||
{
|
||||
public function handle(SelectFieldType $fieldType)
|
||||
{
|
||||
$fieldType->setOptions(
|
||||
[
|
||||
'1' => trans('visiosoft.module.profile::field.individual.name'),
|
||||
'2' => trans('visiosoft.module.profile::field.corporate.name')
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,6 @@
|
||||
<?php namespace Visiosoft\ProfileModule\Profile\Password;
|
||||
|
||||
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
|
||||
use Anomaly\UsersModule\User\UserModel;
|
||||
|
||||
|
||||
class PasswordFormBuilder extends FormBuilder
|
||||
|
||||
@ -2,17 +2,14 @@
|
||||
|
||||
use Anomaly\Streams\Platform\Message\MessageBag;
|
||||
use Anomaly\UsersModule\User\User;
|
||||
use Anomaly\UsersModule\User\UserModel;
|
||||
use Anomaly\UsersModule\User\UserPassword;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class PasswordFormHandler
|
||||
{
|
||||
public function handle(
|
||||
PasswordFormBuilder $builder,
|
||||
MessageBag $messages,
|
||||
UserModel $userModel,
|
||||
UserPassword $userPassword
|
||||
|
||||
)
|
||||
|
||||
@ -1,20 +1,17 @@
|
||||
<?php namespace Visiosoft\ProfileModule\Profile\Profile;
|
||||
|
||||
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
|
||||
use Visiosoft\ProfileModule\Profile\ProfileModel;
|
||||
|
||||
use Anomaly\UsersModule\User\UserModel;
|
||||
|
||||
class ProfileFormBuilder extends FormBuilder
|
||||
{
|
||||
|
||||
protected $model = ProfileModel::class;
|
||||
protected $model = UserModel::class;
|
||||
|
||||
protected $fields = [
|
||||
'file',
|
||||
'gsm_phone',
|
||||
'office_phone',
|
||||
'land_phone',
|
||||
'adv_listing_banner',
|
||||
'identification_number',
|
||||
'register_type'
|
||||
];
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
<?php namespace Visiosoft\ProfileModule\Profile\Profile;
|
||||
|
||||
use Anomaly\Streams\Platform\Message\MessageBag;
|
||||
use Anomaly\UsersModule\User\UserModel;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Visiosoft\ProfileModule\Profile\ProfileModel;
|
||||
|
||||
class ProfileFormHandler
|
||||
{
|
||||
public function handle(
|
||||
ProfileFormBuilder $builder,
|
||||
MessageBag $messages,
|
||||
ProfileModel $profileModel
|
||||
UserModel $userModel
|
||||
)
|
||||
{
|
||||
if (!$builder->canSave()) {
|
||||
@ -22,15 +22,13 @@ class ProfileFormHandler
|
||||
'land_phone' => $builder->getPostValue('land_phone'),
|
||||
'identification_number' => $builder->getPostValue('identification_number'),
|
||||
'register_type' => $builder->getPostValue('register_type'),
|
||||
'adv_listing_banner_id' => $builder->getPostValue('adv_listing_banner'),
|
||||
];
|
||||
|
||||
if ($builder->getPostValue('file') != null)
|
||||
if ($builder->getPostValue('file') != null) {
|
||||
$parameters['file_id'] = $builder->getPostValue('file');
|
||||
}
|
||||
|
||||
|
||||
$profileModel->where('user_id', Auth::id())
|
||||
->update($parameters);
|
||||
$userModel->newQuery()->where('id', Auth::id())->update($parameters);
|
||||
|
||||
$messages->success(trans('visiosoft.module.profile::message.success_update'));
|
||||
}
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
<?php namespace Visiosoft\ProfileModule\Profile;
|
||||
|
||||
use Anomaly\Streams\Platform\Entry\EntryCollection;
|
||||
|
||||
class ProfileCollection extends EntryCollection
|
||||
{
|
||||
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
<?php namespace Visiosoft\ProfileModule\Profile;
|
||||
|
||||
use Anomaly\Streams\Platform\Entry\EntryCriteria;
|
||||
|
||||
class ProfileCriteria extends EntryCriteria
|
||||
{
|
||||
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
<?php namespace Visiosoft\ProfileModule\Profile;
|
||||
|
||||
use Visiosoft\ProfileModule\Profile\Contract\ProfileInterface;
|
||||
use Anomaly\Streams\Platform\Model\Profile\ProfileProfileEntryModel;
|
||||
|
||||
class ProfileModel extends ProfileProfileEntryModel implements ProfileInterface
|
||||
{
|
||||
public function getProfile($id = null)
|
||||
{
|
||||
if($id != null) {
|
||||
return $this->query()->where('user_id', $id);
|
||||
}
|
||||
return $this->query();
|
||||
}
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
<?php namespace Visiosoft\ProfileModule\Profile;
|
||||
|
||||
use Anomaly\Streams\Platform\Entry\EntryObserver;
|
||||
|
||||
class ProfileObserver extends EntryObserver
|
||||
{
|
||||
|
||||
}
|
||||
@ -1,148 +0,0 @@
|
||||
<?php namespace Visiosoft\ProfileModule\Profile;
|
||||
|
||||
use Anomaly\Streams\Platform\Model\Users\UsersUsersEntryModel;
|
||||
use Anomaly\UsersModule\User\Password\Command\SendResetEmail;
|
||||
use Anomaly\UsersModule\User\Password\Command\StartPasswordReset;
|
||||
use Anomaly\UsersModule\User\Password\ForgotPasswordFormHandler;
|
||||
use Anomaly\UsersModule\User\UserModel;
|
||||
use Anomaly\UsersModule\User\UserPassword;
|
||||
use function CoffeeScript\t;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Visiosoft\ProfileModule\Http\Controller\MyProfileController;
|
||||
use Visiosoft\ProfileModule\Profile\Contract\ProfileRepositoryInterface;
|
||||
use Anomaly\Streams\Platform\Entry\EntryRepository;
|
||||
|
||||
class ProfileRepository extends EntryRepository implements ProfileRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* The entry model.
|
||||
*
|
||||
* @var ProfileModel
|
||||
*/
|
||||
protected $model;
|
||||
|
||||
/**
|
||||
* Create a new ProfileRepository instance.
|
||||
*
|
||||
* @param ProfileModel $model
|
||||
*/
|
||||
public function __construct(ProfileModel $model)
|
||||
{
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
public function getUser($id)
|
||||
{
|
||||
return UsersUsersEntryModel::query()->where('users_users.id', $id)->first();
|
||||
}
|
||||
|
||||
public function getProfile($id)
|
||||
{
|
||||
return ProfileModel::query()->where('user_id', $id)->first();
|
||||
}
|
||||
|
||||
public function findUserForLogin($field, $val)
|
||||
{
|
||||
$user = UserModel::query()->where($field, $val)->first();
|
||||
if ($user == null) {
|
||||
$profile = $this->findProfileForLogin('gsm_phone', $val);
|
||||
if ($profile != null) {
|
||||
$user = UserModel::query()->find($profile->user_id);
|
||||
}
|
||||
}
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function findProfileForLogin($field, $val)
|
||||
{
|
||||
return ProfileModel::query()->where($field, $val)->first();
|
||||
}
|
||||
|
||||
public function validPasswordByEmail($email)
|
||||
{
|
||||
return $this->oldUserSendForgotMail($this->findUserForLogin('email', $email));
|
||||
}
|
||||
|
||||
public function validPasswordByUsername($username)
|
||||
{
|
||||
return $this->oldUserSendForgotMail($this->findUserForLogin('username', $username));
|
||||
}
|
||||
|
||||
public function oldUserSendForgotMail($user)
|
||||
{
|
||||
if ($user == null) {
|
||||
return "noUser";
|
||||
}
|
||||
if ($user->password == "alp236330" OR $user->password == "") {
|
||||
if ($user->email == "user2019" . $user->id . "@mail.com") {
|
||||
return "noMail";
|
||||
}
|
||||
$users = new UserPassword();
|
||||
$users->send($user, '/');
|
||||
return "reset";
|
||||
}
|
||||
return "yes";
|
||||
}
|
||||
|
||||
public function updateUserField($fields)
|
||||
{
|
||||
$userModule = [];
|
||||
$userModule['display_name'] = $fields['first_name'] . " " . $fields['last_name'];
|
||||
$userModule['first_name'] = $fields['first_name'];
|
||||
$userModule['last_name'] = $fields['last_name'];
|
||||
//Core User Module
|
||||
UsersUsersEntryModel::query()->find(Auth::id())->update($userModule);
|
||||
foreach ($userModule as $key => $val) {
|
||||
unset($fields[$key]);
|
||||
}
|
||||
return $fields;
|
||||
|
||||
}
|
||||
|
||||
public function changePassword($fields, $userPassword)
|
||||
{
|
||||
if ($fields['new_password'] != $fields['re_new_password']) {
|
||||
$errorList[] = trans('anomaly.module.users::field.confirm_password.name');
|
||||
$fields['error'] = $errorList;
|
||||
return $fields;
|
||||
}
|
||||
|
||||
$validator = $userPassword->validate($fields['new_password']);
|
||||
$errorList = array();
|
||||
foreach ($validator->errors()->all() as $error) {
|
||||
$errorList[] = $error;
|
||||
}
|
||||
if (count($errorList) != 0) {
|
||||
$fields['error'] = $errorList;
|
||||
return $fields;
|
||||
}
|
||||
|
||||
UsersUsersEntryModel::query()->find(Auth::id())->update(['password' => Hash::make($fields['new_password'])]);
|
||||
unset($fields['new_password'], $fields['re_new_password'], $fields['confirm_password_input']);
|
||||
return $fields;
|
||||
}
|
||||
|
||||
public function findByUserID($id)
|
||||
{
|
||||
return $this->model->where('user_id', $id)->first();
|
||||
}
|
||||
|
||||
public function CheckPhoneNumber($phoneNumber)
|
||||
{
|
||||
return $this->model
|
||||
->where('gsm_phone', $phoneNumber)
|
||||
->where('user_id','!=', Auth::id())
|
||||
->first();
|
||||
}
|
||||
|
||||
public function findPhoneNumber($phone_number)
|
||||
{
|
||||
return $this->model->where('gsm_phone', $phone_number)
|
||||
->first();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
<?php namespace Visiosoft\ProfileModule\Profile;
|
||||
|
||||
use Anomaly\Streams\Platform\Entry\EntryRouter;
|
||||
|
||||
class ProfileRouter extends EntryRouter
|
||||
{
|
||||
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
<?php namespace Visiosoft\ProfileModule\Profile;
|
||||
|
||||
use Anomaly\Streams\Platform\Database\Seeder\Seeder;
|
||||
|
||||
class ProfileSeeder extends Seeder
|
||||
{
|
||||
|
||||
/**
|
||||
* Run the seeder.
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@ -41,9 +41,6 @@ class Register2FormBuilder extends FormBuilder
|
||||
'username' => [
|
||||
'required' => true,
|
||||
],
|
||||
'phone' => [
|
||||
'type' => 'anomaly.field_type.text',
|
||||
],
|
||||
'first_name' => [
|
||||
'instructions' => false,
|
||||
'required' => true,
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
use Anomaly\UsersModule\User\Contract\UserInterface;
|
||||
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
|
||||
use Anomaly\UsersModule\User\Event\UserHasRegistered;
|
||||
use Visiosoft\ProfileModule\Profile\ProfileModel;
|
||||
use Anomaly\UsersModule\User\UserActivator;
|
||||
use Illuminate\Contracts\Config\Repository;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
@ -25,9 +24,10 @@ class Register2FormHandler
|
||||
* Handle the form.
|
||||
*
|
||||
* @param Repository $config
|
||||
* @param RegisterFormBuilder $builder
|
||||
* @param Dispatcher $events
|
||||
* @param UserRepositoryInterface $users
|
||||
* @param Register2FormBuilder $builder
|
||||
* @param UserActivator $activator
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function handle(
|
||||
Repository $config,
|
||||
@ -41,7 +41,6 @@ class Register2FormHandler
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$profile_parameters = array();
|
||||
|
||||
/* Create Profile in Register */
|
||||
@ -51,16 +50,14 @@ class Register2FormHandler
|
||||
$domain = str_replace('/', '', $domain);
|
||||
$domain = str_replace('www', '', $domain);
|
||||
|
||||
$profile_parameters['gsm_phone'] = $builder->getPostValue('phone');
|
||||
if (!setting_value('visiosoft.module.advs::register_email_field')) {
|
||||
$builder->setFormValue('email', $builder->getPostValue('username') . "@" . $domain);
|
||||
}
|
||||
|
||||
$fields = $builder->getPostData();
|
||||
$fields['display_name'] = $fields['first_name'] . " " . $fields['last_name'];
|
||||
$fields['gsm_phone'] = $builder->getPostValue('phone');
|
||||
unset($fields['phone']);
|
||||
unset($fields['phone']);
|
||||
|
||||
|
||||
$register = $users->create($fields);
|
||||
$register->setAttribute('password', $fields['password']);
|
||||
@ -68,8 +65,6 @@ class Register2FormHandler
|
||||
|
||||
/* @var UserInterface $user */
|
||||
$user = $register;
|
||||
$profile_parameters['user_id'] = $user->getId();
|
||||
ProfileModel::query()->create($profile_parameters);
|
||||
|
||||
$activator->start($user);
|
||||
$activator->force($user);
|
||||
|
||||
@ -1,79 +0,0 @@
|
||||
<?php namespace Visiosoft\ProfileModule\Profile\Table;
|
||||
|
||||
use Anomaly\Streams\Platform\Ui\Table\TableBuilder;
|
||||
|
||||
class ProfileTableBuilder extends TableBuilder
|
||||
{
|
||||
|
||||
/**
|
||||
* The table views.
|
||||
*
|
||||
* @var array|string
|
||||
*/
|
||||
protected $views = [];
|
||||
|
||||
/**
|
||||
* The table filters.
|
||||
*
|
||||
* @var array|string
|
||||
*/
|
||||
protected $filters = [
|
||||
'search' => [
|
||||
'filter' => 'search',
|
||||
'fields' => [
|
||||
'gsm_phone',
|
||||
'land_phone','office_phone','register_type',
|
||||
'identification_number',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The table columns.
|
||||
*
|
||||
* @var array|string
|
||||
*/
|
||||
protected $columns = [
|
||||
'username','first_name','last_name'
|
||||
];
|
||||
|
||||
/**
|
||||
* The table buttons.
|
||||
*
|
||||
* @var array|string
|
||||
*/
|
||||
protected $buttons = [
|
||||
'go_user'=> [
|
||||
'type' => 'info',
|
||||
'icon' => 'fa fa-user',
|
||||
'href' => '/admin/users/edit/{entry.user_id}'
|
||||
],
|
||||
'edit' => [
|
||||
'text' => 'visiosoft.module.profile::button.go_profile'
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The table actions.
|
||||
*
|
||||
* @var array|string
|
||||
*/
|
||||
protected $actions = [
|
||||
'delete'
|
||||
];
|
||||
|
||||
/**
|
||||
* The table options.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $options = [];
|
||||
|
||||
/**
|
||||
* The table assets.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $assets = [];
|
||||
|
||||
}
|
||||
@ -6,7 +6,6 @@ use Anomaly\UsersModule\User\Contract\UserInterface;
|
||||
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Visiosoft\ProfileModule\Profile\Contract\ProfileRepositoryInterface;
|
||||
use Visiosoft\ProfileModule\Profile\SignIn\SignInFormBuilder;
|
||||
|
||||
|
||||
@ -14,13 +13,11 @@ class ValidateCredentials
|
||||
{
|
||||
public function __construct(
|
||||
ExtensionCollection $extensions,
|
||||
UserRepositoryInterface $userRepository,
|
||||
ProfileRepositoryInterface $profileRepository
|
||||
UserRepositoryInterface $userRepository
|
||||
)
|
||||
{
|
||||
$this->extensions = $extensions;
|
||||
$this->repository = $userRepository;
|
||||
$this->profile = $profileRepository;
|
||||
}
|
||||
|
||||
public function authenticate(array $credentials)
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
<?php namespace Visiosoft\ProfileModule\Profile\Validation;
|
||||
|
||||
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
|
||||
use Visiosoft\ProfileModule\Profile\Contract\ProfileRepositoryInterface;
|
||||
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
|
||||
|
||||
class ValidateRegister
|
||||
{
|
||||
public function handle(FormBuilder $builder, ProfileRepositoryInterface $profileRepository, $attribute, $value)
|
||||
public function handle(FormBuilder $builder, UserRepositoryInterface $userRepository, $attribute, $value)
|
||||
{
|
||||
if (!is_numeric($builder->getPostValue('phone'))) {
|
||||
$builder->addFormError('phone', trans('visiosoft.module.profile::message.error_valid_phone'));
|
||||
return false;
|
||||
} elseif (!is_null($profileRepository->findPhoneNumber($builder->getPostValue('phone')))) {
|
||||
} elseif (!is_null($userRepository->newQuery()->where('gsm_phone', $builder->getPostValue('phone'))->first())) {
|
||||
$builder->addFormError('phone', trans('visiosoft.module.profile::message.registered_phone'));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -25,13 +25,6 @@ class ProfileModule extends Module
|
||||
* @var array
|
||||
*/
|
||||
protected $sections = [
|
||||
'profile' => [
|
||||
'buttons' => [
|
||||
'new_profile'=> [
|
||||
'href' => 'admin/users/create',
|
||||
],
|
||||
],
|
||||
],
|
||||
'adress' => [
|
||||
'buttons' => [
|
||||
'new_adress',
|
||||
|
||||
@ -2,28 +2,15 @@
|
||||
|
||||
use Anomaly\Streams\Platform\Addon\Plugin\Plugin;
|
||||
use Visiosoft\ProfileModule\Adress\Command\GetAddress;
|
||||
use Visiosoft\ProfileModule\Profile\Command\FindUserProfile;
|
||||
|
||||
class ProfileModulePlugin extends Plugin
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new \Twig_SimpleFunction(
|
||||
'findUserProfile',
|
||||
function ($id) {
|
||||
|
||||
if (!$ad = $this->dispatch(new FindUserProfile($id))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $ad;
|
||||
}
|
||||
),
|
||||
new \Twig_SimpleFunction(
|
||||
'getAddress',
|
||||
function ($id) {
|
||||
|
||||
@ -3,11 +3,7 @@
|
||||
use Anomaly\FilesModule\Disk\Contract\DiskRepositoryInterface;
|
||||
use Anomaly\FilesModule\Folder\Contract\FolderRepositoryInterface;
|
||||
use Anomaly\Streams\Platform\Database\Seeder\Seeder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Chumper\Zipper\Zipper;
|
||||
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Visiosoft\ProfileModule\Seed\UsersFieldsSeeder;
|
||||
|
||||
class ProfileModuleSeeder extends Seeder
|
||||
{
|
||||
@ -34,6 +30,8 @@ class ProfileModuleSeeder extends Seeder
|
||||
*/
|
||||
public function __construct(DiskRepositoryInterface $disks, FolderRepositoryInterface $folders)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->disks = $disks;
|
||||
$this->folders = $folders;
|
||||
}
|
||||
@ -43,28 +41,13 @@ class ProfileModuleSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$disk = $this->disks->findBySlug('local');
|
||||
// Users Fields Seeder
|
||||
$this->call(UsersFieldsSeeder::class);
|
||||
|
||||
$this->folders->create(
|
||||
[
|
||||
'en' => [
|
||||
'name' => 'ADV LISTING PAGE IMAGE',
|
||||
'description' => 'A folder for adv listing page images.',
|
||||
],
|
||||
'slug' => 'adv_listing_page',
|
||||
'disk' => $disk,
|
||||
'allowed_types' => [
|
||||
'png',
|
||||
'jpeg',
|
||||
'jpg',
|
||||
],
|
||||
]
|
||||
);
|
||||
if (is_null($this->folders->findBy('slug', 'favicon'))) {
|
||||
$disk = $this->disks->findBySlug('local');
|
||||
|
||||
$disk = $this->disks->findBySlug('local');
|
||||
|
||||
$this->folders->create(
|
||||
[
|
||||
$this->folders->create([
|
||||
'en' => [
|
||||
'name' => 'Favicon',
|
||||
'description' => 'A folder for Favicon.',
|
||||
@ -74,21 +57,7 @@ class ProfileModuleSeeder extends Seeder
|
||||
'allowed_types' => [
|
||||
'ico','png',
|
||||
],
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
|
||||
$repository = "https://raw.githubusercontent.com/openclassify/Openclassify-Demo-Data/master/";
|
||||
file_put_contents(__DIR__ . "/advListingPage.sql", fopen($repository . "advListingPage.sql", 'r'));
|
||||
file_put_contents("adv_listing_page.zip", fopen($repository . "adv_listing_page.zip", 'r'));
|
||||
$zipper = new Zipper();
|
||||
$zipper->make('adv_listing_page.zip')->folder('adv_listing_page')->extractTo(base_path() . '/public/app/default/files-module/local/adv_listing_page/');
|
||||
$zipper->close();
|
||||
|
||||
Model::unguard();
|
||||
DB::unprepared(file_get_contents(__DIR__ . '/advListingPage.sql'));
|
||||
Model::reguard();
|
||||
]);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@ -6,12 +6,8 @@ use Visiosoft\ProfileModule\Adress\Contract\AdressRepositoryInterface;
|
||||
use Visiosoft\ProfileModule\Adress\AdressRepository;
|
||||
use Anomaly\Streams\Platform\Model\Profile\ProfileAdressEntryModel;
|
||||
use Visiosoft\ProfileModule\Adress\AdressModel;
|
||||
use Visiosoft\ProfileModule\Profile\Contract\ProfileRepositoryInterface;
|
||||
use Visiosoft\ProfileModule\Profile\Password\PasswordFormBuilder;
|
||||
use Visiosoft\ProfileModule\Profile\Profile\ProfileFormBuilder;
|
||||
use Visiosoft\ProfileModule\Profile\ProfileRepository;
|
||||
use Anomaly\Streams\Platform\Model\Profile\ProfileProfileEntryModel;
|
||||
use Visiosoft\ProfileModule\Profile\ProfileModel;
|
||||
use Illuminate\Routing\Router;
|
||||
use Visiosoft\ProfileModule\Profile\Register2\Register2FormBuilder;
|
||||
use Visiosoft\ProfileModule\Profile\SignIn\SignInFormBuilder;
|
||||
@ -64,11 +60,11 @@ class ProfileModuleServiceProvider extends AddonServiceProvider
|
||||
],
|
||||
|
||||
/*Address */
|
||||
'admin/profile/adress' => 'Visiosoft\ProfileModule\Http\Controller\Admin\AdressController@index',
|
||||
'admin/profile/adress/create' => 'Visiosoft\ProfileModule\Http\Controller\Admin\AdressController@create',
|
||||
'admin/profile/adress/edit/{id}' => 'Visiosoft\ProfileModule\Http\Controller\Admin\AdressController@adresList',
|
||||
'admin/profile/adress/editAdress/{id}' => 'Visiosoft\ProfileModule\Http\Controller\Admin\AdressController@edit',
|
||||
'admin/profile/adress/update/{id}' => 'Visiosoft\ProfileModule\Http\Controller\Admin\AdressController@adressupdate',
|
||||
'admin/profile' => 'Visiosoft\ProfileModule\Http\Controller\Admin\AdressController@index',
|
||||
'admin/profile/create' => 'Visiosoft\ProfileModule\Http\Controller\Admin\AdressController@create',
|
||||
'admin/profile/edit/{id}' => 'Visiosoft\ProfileModule\Http\Controller\Admin\AdressController@adresList',
|
||||
'admin/profile/editAdress/{id}' => 'Visiosoft\ProfileModule\Http\Controller\Admin\AdressController@edit',
|
||||
'admin/profile/update/{id}' => 'Visiosoft\ProfileModule\Http\Controller\Admin\AdressController@adressupdate',
|
||||
'profile/adress/update/{id}' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@adressUpdate',
|
||||
'profile/address' => [
|
||||
'as' => 'profile::address',
|
||||
@ -100,9 +96,6 @@ class ProfileModuleServiceProvider extends AddonServiceProvider
|
||||
],
|
||||
|
||||
/* Profile */
|
||||
'admin/profile' => 'Visiosoft\ProfileModule\Http\Controller\Admin\ProfileController@index',
|
||||
'admin/profile/edit/{id}' => 'Visiosoft\ProfileModule\Http\Controller\Admin\ProfileController@edit',
|
||||
'admin/profile/update/{id}' => 'Visiosoft\ProfileModule\Http\Controller\Admin\ProfileController@update',
|
||||
'profile/edit' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@edit',
|
||||
'profile/update' => 'Visiosoft\ProfileModule\Http\Controller\MyProfileController@update',
|
||||
'profile' => [
|
||||
@ -190,7 +183,6 @@ class ProfileModuleServiceProvider extends AddonServiceProvider
|
||||
'profile' => ProfileFormBuilder::class,
|
||||
'signIn' => SignInFormBuilder::class,
|
||||
ProfileAdressEntryModel::class => AdressModel::class,
|
||||
ProfileProfileEntryModel::class => ProfileModel::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@ -200,7 +192,6 @@ class ProfileModuleServiceProvider extends AddonServiceProvider
|
||||
*/
|
||||
protected $singletons = [
|
||||
AdressRepositoryInterface::class => AdressRepository::class,
|
||||
ProfileRepositoryInterface::class => ProfileRepository::class,
|
||||
'register2' => Register2FormBuilder::class,
|
||||
'sites' => SitesFormBuilder::class,
|
||||
];
|
||||
|
||||
@ -0,0 +1,194 @@
|
||||
<?php namespace Visiosoft\ProfileModule\Seed;
|
||||
|
||||
use Anomaly\Streams\Platform\Assignment\AssignmentModelTranslation;
|
||||
use Anomaly\Streams\Platform\Assignment\Contract\AssignmentRepositoryInterface;
|
||||
use Anomaly\Streams\Platform\Database\Seeder\Seeder;
|
||||
use Anomaly\Streams\Platform\Entry\EntryTranslationsModel;
|
||||
use Anomaly\Streams\Platform\Field\Contract\FieldRepositoryInterface;
|
||||
use Anomaly\Streams\Platform\Field\FieldModelTranslation;
|
||||
use Anomaly\Streams\Platform\Stream\Contract\StreamRepositoryInterface;
|
||||
use Anomaly\Streams\Platform\Stream\StreamModelTranslation;
|
||||
use Visiosoft\LocationModule\Country\CountryModel;
|
||||
|
||||
class UsersFieldsSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the seeder.
|
||||
* @param FieldRepositoryInterface $fieldRepository
|
||||
* @param AssignmentRepositoryInterface $assignmentRepository
|
||||
* @param StreamRepositoryInterface $streamRepository
|
||||
* @param FieldModelTranslation $fieldModelTranslation
|
||||
* @param AssignmentModelTranslation $assignmentModelTranslation
|
||||
*/
|
||||
public function run(
|
||||
FieldRepositoryInterface $fieldRepository,
|
||||
AssignmentRepositoryInterface $assignmentRepository,
|
||||
StreamRepositoryInterface $streamRepository,
|
||||
FieldModelTranslation $fieldModelTranslation,
|
||||
AssignmentModelTranslation $assignmentModelTranslation
|
||||
)
|
||||
{
|
||||
$namespace = 'users';
|
||||
$locked = 0;
|
||||
$stream = $streamRepository->findBy('slug', 'users');
|
||||
$assignmentConfig = 'a:0:{}';
|
||||
|
||||
$customFields = [
|
||||
0 => [
|
||||
'name' => 'File',
|
||||
'slug' => 'file',
|
||||
'type' => 'visiosoft.field_type.singlefile',
|
||||
'config' => [
|
||||
'folders' => ["images"],
|
||||
'mode' => 'upload',
|
||||
]
|
||||
],
|
||||
1 => [
|
||||
'name' => 'Country',
|
||||
'slug' => 'country',
|
||||
'type' => 'anomaly.field_type.relationship',
|
||||
'config' => [
|
||||
'related' => CountryModel::class,
|
||||
"default_value" => 0,
|
||||
],
|
||||
],
|
||||
2 => [
|
||||
'name' => 'City',
|
||||
'slug' => 'city',
|
||||
'type' => 'anomaly.field_type.select',
|
||||
"config" => [
|
||||
"options" => [],
|
||||
]
|
||||
],
|
||||
3 => [
|
||||
'name' => 'District',
|
||||
'slug' => 'district',
|
||||
'type' => 'anomaly.field_type.select',
|
||||
"config" => [
|
||||
"options" => [],
|
||||
]
|
||||
],
|
||||
4 => [
|
||||
'name' => 'Neighborhood',
|
||||
'slug' => 'neighborhood',
|
||||
'type' => 'anomaly.field_type.select',
|
||||
"config" => [
|
||||
"options" => [],
|
||||
]
|
||||
],
|
||||
5 => [
|
||||
'name' => 'Village',
|
||||
'slug' => 'village',
|
||||
'type' => 'anomaly.field_type.select',
|
||||
"config" => [
|
||||
"options" => [],
|
||||
]
|
||||
],
|
||||
6 => [
|
||||
'name' => 'Gsm Phone',
|
||||
'slug' => 'gsm_phone',
|
||||
'type' => 'anomaly.field_type.text',
|
||||
],
|
||||
7 => [
|
||||
'name' => 'Land Phone',
|
||||
'slug' => 'land_phone',
|
||||
'type' => 'anomaly.field_type.text',
|
||||
],
|
||||
8 => [
|
||||
'name' => 'Office Phone',
|
||||
'slug' => 'office_phone',
|
||||
'type' => 'anomaly.field_type.text',
|
||||
],
|
||||
9 => [
|
||||
'name' => 'Register Type',
|
||||
'slug' => 'register_type',
|
||||
'type' => 'anomaly.field_type.select',
|
||||
"config" => [
|
||||
"options" => [
|
||||
'1' => trans('visiosoft.module.profile::field.individual.name'),
|
||||
'2' => trans('visiosoft.module.profile::field.corporate.name')
|
||||
],
|
||||
]
|
||||
],
|
||||
10 => [
|
||||
'name' => 'Identification Number',
|
||||
'slug' => 'identification_number',
|
||||
'type' => 'anomaly.field_type.text',
|
||||
],
|
||||
11 => [
|
||||
'name' => 'Notified New Updates',
|
||||
'slug' => 'notified_new_updates',
|
||||
'type' => 'anomaly.field_type.select',
|
||||
'config' => [
|
||||
'default_value' => 1,
|
||||
'options' => [0 => 'Active', 1 => 'Passive'],
|
||||
'separator' => ':',
|
||||
]
|
||||
],
|
||||
12 => [
|
||||
'name' => 'Notified About Ads',
|
||||
'slug' => 'notified_about_ads',
|
||||
'type' => 'anomaly.field_type.select',
|
||||
'config' => [
|
||||
'default_value' => 1,
|
||||
'options' => [0 => 'Active', 1 => 'Passive'],
|
||||
'separator' => ':',
|
||||
]
|
||||
],
|
||||
13 => [
|
||||
'name' => 'Receive Messages Email',
|
||||
'slug' => 'receive_messages_email',
|
||||
'type' => 'anomaly.field_type.select',
|
||||
'config' => [
|
||||
'default_value' => 1,
|
||||
'options' => [0 => 'Active', 1 => 'Passive'],
|
||||
'separator' => ':',
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($customFields as $customField) {
|
||||
$fields = $fieldRepository
|
||||
->newQuery()
|
||||
->where('slug', $customField['slug'])
|
||||
->where('namespace', $namespace)
|
||||
->get();
|
||||
|
||||
if ($fields) {
|
||||
foreach ($fields as $field) {
|
||||
$fieldModelTranslation->newQuery()->where('field_id', $field->id)->delete();
|
||||
|
||||
$assignment = $assignmentRepository
|
||||
->newQuery()
|
||||
->where('stream_id', $stream->id)
|
||||
->where('field_id', $field->id)
|
||||
->first();
|
||||
if ($assignment) {
|
||||
$assignmentModelTranslation->newQuery()->where('assignment_id', $assignment->id)->delete();
|
||||
$assignment->delete();
|
||||
}
|
||||
|
||||
$field->delete();
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'name' => $customField['name'],
|
||||
'namespace' => $namespace,
|
||||
'slug' => $customField['slug'],
|
||||
'type' => $customField['type'],
|
||||
'locked' => $locked
|
||||
];
|
||||
if (isset($customField['config'])) {
|
||||
$data['config'] = $customField['config'];
|
||||
}
|
||||
|
||||
$field = $fieldRepository->create($data);
|
||||
|
||||
$assignmentRepository->create([
|
||||
'stream_id' => $stream->id,
|
||||
'field_id' => $field->id
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'title' => 'File',
|
||||
'title' => 'Single File',
|
||||
'name' => 'File Field Type',
|
||||
'description' => 'A file upload field type.',
|
||||
];
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'title' => 'Dosya',
|
||||
'title' => 'Tek Dosya',
|
||||
'name' => 'Dosya Alan Tipi',
|
||||
'description' => 'Bir dosya yükleme alan tipi.',
|
||||
];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user