mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-09 06:46:08 -06:00
#996 Merge profile and users module
This commit is contained in:
parent
528bca0c62
commit
2f6823d58e
@ -26,7 +26,6 @@
|
|||||||
<!--detail-ad -->
|
<!--detail-ad -->
|
||||||
<div class="section slider mb-4">
|
<div class="section slider mb-4">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
{% include "visiosoft.module.advs::ad-detail/partials/slider" %}
|
{% include "visiosoft.module.advs::ad-detail/partials/slider" %}
|
||||||
<div class="col-md-5">
|
<div class="col-md-5">
|
||||||
{% if setting_value('visiosoft.theme.base::ad_details') %}
|
{% if setting_value('visiosoft.theme.base::ad_details') %}
|
||||||
|
|||||||
@ -46,11 +46,9 @@ class AdvPresenter extends EntryPresenter
|
|||||||
|
|
||||||
public function isCorporate()
|
public function isCorporate()
|
||||||
{
|
{
|
||||||
$user_id = $this->getObject()->created_by_id;
|
$user_id = $this->getObject()->created_by;
|
||||||
$profile = new ProfileModel();
|
if ($user_id->register_type != null) {
|
||||||
$profile = $profile->getProfile($user_id)->first();
|
return $user_id->register_type;
|
||||||
if ($profile != null) {
|
|
||||||
return $profile->register_type;
|
|
||||||
} else {
|
} else {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -352,9 +352,6 @@ class AdvsController extends PublicController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile = $this->profile_model->getProfile($adv->created_by_id)->first();
|
|
||||||
|
|
||||||
|
|
||||||
if ($isCommentActive) {
|
if ($isCommentActive) {
|
||||||
$CommentModel = new CommentModel();
|
$CommentModel = new CommentModel();
|
||||||
$comments = $CommentModel->getComments($adv->id)->get();
|
$comments = $CommentModel->getComments($adv->id)->get();
|
||||||
@ -367,7 +364,7 @@ class AdvsController extends PublicController
|
|||||||
$this->template->set('meta_image', $adv->cover_photo);
|
$this->template->set('meta_image', $adv->cover_photo);
|
||||||
|
|
||||||
if ($adv->created_by_id == isset(auth()->user()->id) OR $adv->status == "approved") {
|
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 {
|
} else {
|
||||||
return back();
|
return back();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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::$defaultView = 'visiosoft.theme.defaultadmin::pagination/bootstrap-4';
|
||||||
AbstractPaginator::$defaultSimpleView = 'streams::pagination/simple-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 %}
|
{% set showTheme = true %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if showTheme %}
|
{% if showTheme %}
|
||||||
{% set profile = findUserProfile(params.adv.created_by_id) %}
|
{% set user = params.adv.created_by %}
|
||||||
{% if profile.gsm_phone is not null %}
|
{% if user.gsm_phone is not null %}
|
||||||
<div class="col-md-12 m-2 number-container">
|
<div class="col-md-12 m-2 number-container">
|
||||||
<button class="btn btn-secondary w-100">
|
<button class="btn btn-secondary w-100">
|
||||||
<i class="fas fa-mobile hide-number text-warning"></i>
|
<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>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if profile.office_phone is not empty %}
|
{% if user.office_phone is not empty %}
|
||||||
<div class="col-md-12 m-2 number-container">
|
<div class="col-md-12 m-2 number-container">
|
||||||
<button class="btn btn-secondary w-100">
|
<button class="btn btn-secondary w-100">
|
||||||
<i class="fas fa-headset hide-number text-warning"></i>
|
<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>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if profile.land_phone is not empty %}
|
{% if user.land_phone is not empty %}
|
||||||
<div class="col-md-12 m-2 number-container">
|
<div class="col-md-12 m-2 number-container">
|
||||||
<button class="btn btn-secondary w-100">
|
<button class="btn btn-secondary w-100">
|
||||||
<i class="fa fa-phone-square hide-number text-warning"></i>
|
<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>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{% extends "theme::layouts/default" %}
|
{% extends "theme::layouts/default" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% set profile_photo = profiles.file %}
|
{% set profile_photo = user.file %}
|
||||||
{% if profile_photo %}
|
{% if profile_photo %}
|
||||||
{% set profile_photo = file(profile_photo.id).url %}
|
{% set profile_photo = file(profile_photo.id).url %}
|
||||||
{% else %}
|
{% else %}
|
||||||
@ -16,7 +16,6 @@
|
|||||||
<!-- User Profile Detail Section-->
|
<!-- User Profile Detail Section-->
|
||||||
<div class="col-md-12 bg-dark">
|
<div class="col-md-12 bg-dark">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<div class="col-md-4 p-5">
|
<div class="col-md-4 p-5">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{% if setting_value('visiosoft.module.profile::upload_avatar') %}
|
{% if setting_value('visiosoft.module.profile::upload_avatar') %}
|
||||||
@ -26,11 +25,10 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="col-md-12 text-center align-middle text-white p-2 text-truncate">
|
<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>
|
<small>{{ auth_user().last_login_at|date("d/m/Y H:i:s") }}</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -39,7 +37,6 @@
|
|||||||
|
|
||||||
<!-- User Profile Form Section-->
|
<!-- User Profile Form Section-->
|
||||||
<div class="col-md-12 mt-5 bg-light profile-section">
|
<div class="col-md-12 mt-5 bg-light profile-section">
|
||||||
|
|
||||||
<nav>
|
<nav>
|
||||||
<div class="nav nav-tabs nav-fill" id="nav-tab" role="tablist">
|
<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"
|
<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"
|
<div class="tab-pane fade show active" id="nav-profile" role="tabpanel"
|
||||||
aria-labelledby="nav-profile-tab">
|
aria-labelledby="nav-profile-tab">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
{% set userForm = form('userProfile').entry(auth_user().id).get() %}
|
{% set userForm = form('userProfile').entry(user.id).get() %}
|
||||||
{{ userForm.open()|raw }}
|
{{ userForm.open()|raw }}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label font-weight-bold">
|
<label class="control-label font-weight-bold">
|
||||||
@ -83,7 +80,7 @@
|
|||||||
<label class="control-label font-weight-bold">
|
<label class="control-label font-weight-bold">
|
||||||
{{ trans("visiosoft.module.profile::field.email.name") }}
|
{{ trans("visiosoft.module.profile::field.email.name") }}
|
||||||
</label>
|
</label>
|
||||||
<input value="{{ auth_user().email }}" type="text" disabled class="form-control">
|
<input value="{{ user.email }}" type="text" disabled class="form-control">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{{ userForm.actions|raw }}
|
{{ userForm.actions|raw }}
|
||||||
@ -95,7 +92,7 @@
|
|||||||
<div class="tab-pane fade" id="nav-details" role="tabpanel"
|
<div class="tab-pane fade" id="nav-details" role="tabpanel"
|
||||||
aria-labelledby="nav-details-tab">
|
aria-labelledby="nav-details-tab">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
{% set profileForm = form('profile').entry(profiles.id).get() %}
|
{% set profileForm = form('profile').entry(user.id).get() %}
|
||||||
|
|
||||||
{{ profileForm.open()|raw }}
|
{{ profileForm.open()|raw }}
|
||||||
|
|
||||||
|
|||||||
@ -7,6 +7,7 @@ use Anomaly\Streams\Platform\Model\Options\OptionsAdvertisementEntryModel;
|
|||||||
use Anomaly\Streams\Platform\Model\Profile\ProfileAdressEntryModel;
|
use Anomaly\Streams\Platform\Model\Profile\ProfileAdressEntryModel;
|
||||||
use Anomaly\Streams\Platform\Model\Users\UsersUsersEntryModel;
|
use Anomaly\Streams\Platform\Model\Users\UsersUsersEntryModel;
|
||||||
use Anomaly\UsersModule\User\Contract\UserInterface;
|
use Anomaly\UsersModule\User\Contract\UserInterface;
|
||||||
|
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
|
||||||
use Anomaly\UsersModule\User\Password\Command\StartPasswordReset;
|
use Anomaly\UsersModule\User\Password\Command\StartPasswordReset;
|
||||||
use Anomaly\UsersModule\User\UserPassword;
|
use Anomaly\UsersModule\User\UserPassword;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@ -49,10 +50,13 @@ use Illuminate\Contracts\Events\Dispatcher;
|
|||||||
|
|
||||||
class MyProfileController extends PublicController
|
class MyProfileController extends PublicController
|
||||||
{
|
{
|
||||||
|
|
||||||
private $adressRepository;
|
private $adressRepository;
|
||||||
|
private $userRepository;
|
||||||
|
|
||||||
public function __construct(AdressRepositoryInterface $adressRepository)
|
public function __construct(
|
||||||
|
AdressRepositoryInterface $adressRepository,
|
||||||
|
UserRepositoryInterface $userRepository
|
||||||
|
)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
if (!Auth::user()) {
|
if (!Auth::user()) {
|
||||||
@ -60,6 +64,7 @@ class MyProfileController extends PublicController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->adressRepository = $adressRepository;
|
$this->adressRepository = $adressRepository;
|
||||||
|
$this->userRepository = $userRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected $user;
|
protected $user;
|
||||||
@ -69,28 +74,15 @@ class MyProfileController extends PublicController
|
|||||||
//clear empty ads
|
//clear empty ads
|
||||||
$advRepository->delete_empty_advs();
|
$advRepository->delete_empty_advs();
|
||||||
|
|
||||||
$menu_fields = array();
|
|
||||||
$advs_count = new AdvModel();
|
$advs_count = new AdvModel();
|
||||||
$advs_count = count($advs_count->myAdvsByUser()->get());
|
$advs_count = count($advs_count->myAdvsByUser()->get());
|
||||||
|
|
||||||
$profileModel = new ProfileModel();
|
$user = $this->userRepository->find(Auth::id());
|
||||||
|
|
||||||
$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();
|
|
||||||
}
|
|
||||||
|
|
||||||
$country = CountryModel::all();
|
$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',
|
return $this->view->make('visiosoft.module.profile::profile.detail',
|
||||||
'mySales', 'advs_count', 'fav_count', 'userbalance', 'balancespackage'));
|
compact('user','country', 'form', 'advs_count'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,20 +1,17 @@
|
|||||||
<?php namespace Visiosoft\ProfileModule\Profile\Profile;
|
<?php namespace Visiosoft\ProfileModule\Profile\Profile;
|
||||||
|
|
||||||
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
|
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
|
||||||
use Visiosoft\ProfileModule\Profile\ProfileModel;
|
use Anomaly\UsersModule\User\UserModel;
|
||||||
|
|
||||||
|
|
||||||
class ProfileFormBuilder extends FormBuilder
|
class ProfileFormBuilder extends FormBuilder
|
||||||
{
|
{
|
||||||
|
protected $model = UserModel::class;
|
||||||
protected $model = ProfileModel::class;
|
|
||||||
|
|
||||||
protected $fields = [
|
protected $fields = [
|
||||||
'file',
|
'file',
|
||||||
'gsm_phone',
|
'gsm_phone',
|
||||||
'office_phone',
|
'office_phone',
|
||||||
'land_phone',
|
'land_phone',
|
||||||
'adv_listing_banner',
|
|
||||||
'identification_number',
|
'identification_number',
|
||||||
'register_type'
|
'register_type'
|
||||||
];
|
];
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
<?php namespace Visiosoft\ProfileModule\Profile\Profile;
|
<?php namespace Visiosoft\ProfileModule\Profile\Profile;
|
||||||
|
|
||||||
use Anomaly\Streams\Platform\Message\MessageBag;
|
use Anomaly\Streams\Platform\Message\MessageBag;
|
||||||
|
use Anomaly\UsersModule\User\UserModel;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Visiosoft\ProfileModule\Profile\ProfileModel;
|
|
||||||
|
|
||||||
class ProfileFormHandler
|
class ProfileFormHandler
|
||||||
{
|
{
|
||||||
public function handle(
|
public function handle(
|
||||||
ProfileFormBuilder $builder,
|
ProfileFormBuilder $builder,
|
||||||
MessageBag $messages,
|
MessageBag $messages,
|
||||||
ProfileModel $profileModel
|
UserModel $userModel
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (!$builder->canSave()) {
|
if (!$builder->canSave()) {
|
||||||
@ -22,15 +22,13 @@ class ProfileFormHandler
|
|||||||
'land_phone' => $builder->getPostValue('land_phone'),
|
'land_phone' => $builder->getPostValue('land_phone'),
|
||||||
'identification_number' => $builder->getPostValue('identification_number'),
|
'identification_number' => $builder->getPostValue('identification_number'),
|
||||||
'register_type' => $builder->getPostValue('register_type'),
|
'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');
|
$parameters['file_id'] = $builder->getPostValue('file');
|
||||||
|
}
|
||||||
|
|
||||||
|
$userModel->newQuery()->where('id', Auth::id())->update($parameters);
|
||||||
$profileModel->where('user_id', Auth::id())
|
|
||||||
->update($parameters);
|
|
||||||
|
|
||||||
$messages->success(trans('visiosoft.module.profile::message.success_update'));
|
$messages->success(trans('visiosoft.module.profile::message.success_update'));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,9 +25,10 @@ class Register2FormHandler
|
|||||||
* Handle the form.
|
* Handle the form.
|
||||||
*
|
*
|
||||||
* @param Repository $config
|
* @param Repository $config
|
||||||
* @param RegisterFormBuilder $builder
|
* @param Dispatcher $events
|
||||||
|
* @param UserRepositoryInterface $users
|
||||||
|
* @param Register2FormBuilder $builder
|
||||||
* @param UserActivator $activator
|
* @param UserActivator $activator
|
||||||
* @throws \Exception
|
|
||||||
*/
|
*/
|
||||||
public function handle(
|
public function handle(
|
||||||
Repository $config,
|
Repository $config,
|
||||||
@ -41,7 +42,6 @@ class Register2FormHandler
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$profile_parameters = array();
|
$profile_parameters = array();
|
||||||
|
|
||||||
/* Create Profile in Register */
|
/* Create Profile in Register */
|
||||||
@ -51,16 +51,14 @@ class Register2FormHandler
|
|||||||
$domain = str_replace('/', '', $domain);
|
$domain = str_replace('/', '', $domain);
|
||||||
$domain = str_replace('www', '', $domain);
|
$domain = str_replace('www', '', $domain);
|
||||||
|
|
||||||
$profile_parameters['gsm_phone'] = $builder->getPostValue('phone');
|
|
||||||
if (!setting_value('visiosoft.module.advs::register_email_field')) {
|
if (!setting_value('visiosoft.module.advs::register_email_field')) {
|
||||||
$builder->setFormValue('email', $builder->getPostValue('username') . "@" . $domain);
|
$builder->setFormValue('email', $builder->getPostValue('username') . "@" . $domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = $builder->getPostData();
|
$fields = $builder->getPostData();
|
||||||
$fields['display_name'] = $fields['first_name'] . " " . $fields['last_name'];
|
$fields['display_name'] = $fields['first_name'] . " " . $fields['last_name'];
|
||||||
|
$fields['gsm_phone'] = $builder->getPostValue('phone');
|
||||||
unset($fields['phone']);
|
unset($fields['phone']);
|
||||||
unset($fields['phone']);
|
|
||||||
|
|
||||||
|
|
||||||
$register = $users->create($fields);
|
$register = $users->create($fields);
|
||||||
$register->setAttribute('password', $fields['password']);
|
$register->setAttribute('password', $fields['password']);
|
||||||
@ -68,8 +66,6 @@ class Register2FormHandler
|
|||||||
|
|
||||||
/* @var UserInterface $user */
|
/* @var UserInterface $user */
|
||||||
$user = $register;
|
$user = $register;
|
||||||
$profile_parameters['user_id'] = $user->getId();
|
|
||||||
ProfileModel::query()->create($profile_parameters);
|
|
||||||
|
|
||||||
$activator->start($user);
|
$activator->start($user);
|
||||||
$activator->force($user);
|
$activator->force($user);
|
||||||
|
|||||||
@ -1,16 +1,16 @@
|
|||||||
<?php namespace Visiosoft\ProfileModule\Profile\Validation;
|
<?php namespace Visiosoft\ProfileModule\Profile\Validation;
|
||||||
|
|
||||||
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
|
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
|
||||||
use Visiosoft\ProfileModule\Profile\Contract\ProfileRepositoryInterface;
|
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
|
||||||
|
|
||||||
class ValidateRegister
|
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'))) {
|
if (!is_numeric($builder->getPostValue('phone'))) {
|
||||||
$builder->addFormError('phone', trans('visiosoft.module.profile::message.error_valid_phone'));
|
$builder->addFormError('phone', trans('visiosoft.module.profile::message.error_valid_phone'));
|
||||||
return false;
|
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'));
|
$builder->addFormError('phone', trans('visiosoft.module.profile::message.registered_phone'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,9 +5,8 @@ use Anomaly\FilesModule\Folder\Contract\FolderRepositoryInterface;
|
|||||||
use Anomaly\Streams\Platform\Database\Seeder\Seeder;
|
use Anomaly\Streams\Platform\Database\Seeder\Seeder;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Chumper\Zipper\Zipper;
|
use Chumper\Zipper\Zipper;
|
||||||
|
|
||||||
|
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Visiosoft\ProfileModule\Seed\UsersFieldsSeeder;
|
||||||
|
|
||||||
class ProfileModuleSeeder extends Seeder
|
class ProfileModuleSeeder extends Seeder
|
||||||
{
|
{
|
||||||
@ -34,6 +33,8 @@ class ProfileModuleSeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function __construct(DiskRepositoryInterface $disks, FolderRepositoryInterface $folders)
|
public function __construct(DiskRepositoryInterface $disks, FolderRepositoryInterface $folders)
|
||||||
{
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
$this->disks = $disks;
|
$this->disks = $disks;
|
||||||
$this->folders = $folders;
|
$this->folders = $folders;
|
||||||
}
|
}
|
||||||
@ -43,41 +44,38 @@ class ProfileModuleSeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function run()
|
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',
|
|
||||||
],
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
$disk = $this->disks->findBySlug('local');
|
$disk = $this->disks->findBySlug('local');
|
||||||
|
|
||||||
$this->folders->create(
|
$this->folders->create([
|
||||||
[
|
'en' => [
|
||||||
'en' => [
|
'name' => 'ADV LISTING PAGE IMAGE',
|
||||||
'name' => 'Favicon',
|
'description' => 'A folder for adv listing page images.',
|
||||||
'description' => 'A folder for Favicon.',
|
],
|
||||||
],
|
'slug' => 'adv_listing_page',
|
||||||
'slug' => 'favicon',
|
'disk' => $disk,
|
||||||
'disk' => $disk,
|
'allowed_types' => [
|
||||||
'allowed_types' => [
|
'png',
|
||||||
'ico','png',
|
'jpeg',
|
||||||
],
|
'jpg',
|
||||||
]
|
],
|
||||||
);
|
]);
|
||||||
|
|
||||||
|
$disk = $this->disks->findBySlug('local');
|
||||||
|
|
||||||
|
$this->folders->create([
|
||||||
|
'en' => [
|
||||||
|
'name' => 'Favicon',
|
||||||
|
'description' => 'A folder for Favicon.',
|
||||||
|
],
|
||||||
|
'slug' => 'favicon',
|
||||||
|
'disk' => $disk,
|
||||||
|
'allowed_types' => [
|
||||||
|
'ico','png',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
|
||||||
$repository = "https://raw.githubusercontent.com/openclassify/Openclassify-Demo-Data/master/";
|
$repository = "https://raw.githubusercontent.com/openclassify/Openclassify-Demo-Data/master/";
|
||||||
file_put_contents(__DIR__ . "/advListingPage.sql", fopen($repository . "advListingPage.sql", 'r'));
|
file_put_contents(__DIR__ . "/advListingPage.sql", fopen($repository . "advListingPage.sql", 'r'));
|
||||||
|
|||||||
@ -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
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'title' => 'File',
|
'title' => 'Single File',
|
||||||
'name' => 'File Field Type',
|
'name' => 'File Field Type',
|
||||||
'description' => 'A file upload field type.',
|
'description' => 'A file upload field type.',
|
||||||
];
|
];
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'title' => 'Dosya',
|
'title' => 'Tek Dosya',
|
||||||
'name' => 'Dosya Alan Tipi',
|
'name' => 'Dosya Alan Tipi',
|
||||||
'description' => 'Bir dosya yükleme alan tipi.',
|
'description' => 'Bir dosya yükleme alan tipi.',
|
||||||
];
|
];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user