first commit

This commit is contained in:
2024-04-16 15:43:24 +05:45
commit b49e06fa93
4387 changed files with 543889 additions and 0 deletions

View File

@ -0,0 +1,28 @@
<?php
namespace App\Modules\Models\Country;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Country extends Model
{
use HasFactory;
protected $fillable = [
'country_name',
'phone_code',
'country_code',
'status'
];
public function provinces()
{
return $this->hasMany(Province::class);
}
public static function getCountries()
{
return self::select('id','country_name')->where('status','Active')->get();
}
}

View File

@ -0,0 +1,37 @@
<?php
namespace App\Modules\Models\District;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class District extends Model
{
use HasFactory;
protected $fillable = [
'district_name',
'country_id',
'province_id',
'status',
];
public static function getDistricts()
{
return self::select('id', 'district_name')->where('status', 'Active')->get();
}
public static function getDistrictsByProvinceId($province_id)
{
return self::select('id', 'district_name')->where('status', 'Active')->where('state_id',$province_id)->get();
}
public static function getPermDistrictsByProvinceId($province_id)
{
return self::select('id', 'district_name')->where('status', 'Active')->where('state_id',$province_id)->get();
}
public static function getTempDistrictsByProvinceId($province_id)
{
return self::select('id', 'district_name')->where('status', 'Active')->where('state_id',$province_id)->get();
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace App\Modules\Models\Eligibility;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Eligibility extends Model
{
protected $table = 'tbl_eligibilities';
use HasFactory;
protected $fillable = [
'stream',
'program_id',
'level',
'grade',
'display_order',
'remarks',
'status',
'created_by',
'created_on',
];
}

View File

@ -0,0 +1,25 @@
<?php
namespace App\Modules\Models\Fee;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Fee extends Model
{
protected $table = 'tbl_fees';
use HasFactory;
protected $fillable = [
'title',
'program_id',
'type',
'amount',
'display_order',
'remarks',
'status',
'created_by',
'created_on',
];
}

View File

@ -0,0 +1,40 @@
<?php
namespace App\Modules\Models\FollowUp;
use App\Modules\Models\LeadCategory\LeadCategory;
use App\Modules\Models\Registration\Registration;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
class FollowUp extends Model
{
use HasFactory;
protected $table = 'tbl_follow_ups';
protected $fillable = [
'refrence_id',
'follow_up_type',
'next_schedule',
'follow_up_name',
'follow_up_by',
'remarks',
'leadcategory_id',
'status',
'created_by',
'last_updated_by'
];
public static function registration($id)
{
$query = DB::select("SELECT f.id,r.name,r.email,r.phone,f.next_schedule,f.follow_up_by,f.remarks FROM tbl_registrations r INNER JOIN tbl_follow_ups f ON f.refrence_id = r.id AND f.follow_up_type = 'registration' AND f.id = $id");
if(!empty($query)) {
return $query[0];
}
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace App\Modules\Models\Intake;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Intake extends Model
{
protected $table = 'tbl_intakes';
use HasFactory;
protected $fillable = [
'title',
'program_id',
'intake_date',
'class_commencement',
'deadline_date',
'display_order',
'remarks',
'status',
'created_by',
'created_on',
];
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\Modules\Models\LeadCategory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class LeadCategory extends Model
{
use HasFactory;
protected $table = 'tbl_leadcategories';
protected $fillable = [
'name',
'color_code',
'status',
];
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Modules\Models\Location;
use App\Modules\Models\Registration\Registration;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Location extends Model
{
use HasFactory;
protected $table = 'tbl_locations';
protected $fillable = [
'name',
'slug',
'email',
'password',
'description',
'status',
'user_id',
];
public function registrations()
{
return $this->hasMany(Registration::class,'preffered_location','slug');
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace App\Modules\Models\Municipality;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Municipality extends Model
{
use HasFactory;
}

View File

@ -0,0 +1,50 @@
<?php
namespace App\Modules\Models\Permission;
use App\Modules\Models\User;
use App\Modules\Models\Role;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Permission extends Model
{
use HasFactory;
protected $fillable= [
'name', 'slug', 'visibility','status', 'availability','is_deleted','group_name',
'deleted_at','created_by','last_updated_by','last_deleted_by'
];
protected $appends = [
'visibility_text', 'status_text', 'availability_text', 'thumbnail_path', 'image_path'
];
function getVisibilityTextAttribute(){
return ucwords(str_replace('_', ' ', $this->visibility));
}
function getStatusTextAttribute(){
return ucwords(str_replace('_', ' ', $this->status));
}
function getAvailabilityTextAttribute(){
return ucwords(str_replace('_', ' ', $this->availability));
}
function creator(){
return $this->belongsTo(User::class,'created_by');
}
function getImagePathAttribute(){
return $this->path.'/'. $this->image;
}
function getThumbnailPathAttribute(){
return $this->path.'/thumb/'. $this->image;
}
public function roles(){
return $this->belongsToMany(Role::class,'role_has_permissions');
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace App\Modules\Models\Program;
use App\Modules\Models\Criteria\Criteria;
use App\Modules\Models\Eligibility\Eligibility;
use App\Modules\Models\Fee\Fee;
use App\Modules\Models\Intake\Intake;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Program extends Model
{
protected $table = 'tbl_programs';
use HasFactory;
protected $fillable = [
'title',
'description',
'checklist_documents',
'image',
'contact_person',
'contact_email',
'contact_number',
'special_instruction',
'display_order',
'remarks',
'status',
'created_by',
'created_on',
];
public function intakes()
{
return $this->hasMany(Intake::class,'program_id','id');
}
public function fees()
{
return $this->hasMany(Fee::class,'program_id','id');
}
public function eligibilities()
{
return $this->hasMany(Eligibility::class,'program_id','id');
}
public function criterias()
{
return $this->hasMany(Criteria::class,'program_id','id');
}
}

View File

@ -0,0 +1,30 @@
<?php
namespace App\Modules\Models\Province;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Province extends Model
{
use HasFactory;
protected $fillable = [
'province_name',
'country_id',
'status',
];
public function country()
{
return $this->belongsTo(Country::class);
}
public static function getProvinces()
{
return self::select('id','province_name')->where('status','Active')->get();
}
public static function getProvincesByCountryId($country_id)
{
return self::select('id','province_name')->where('status','Active')->where('country_id',$country_id)->get();
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\Modules\Models\Qualification;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Qualification extends Model
{
protected $table = 'tbl_qualifications';
use HasFactory;
protected $fillable = [
'name',
'description',
'status',
];
}

View File

@ -0,0 +1,94 @@
<?php
namespace App\Modules\Models\Registration;
use App\Modules\Models\Campaign\Campaign;
use App\Modules\Models\FollowUp\FollowUp;
use App\Modules\Models\LeadCategory\LeadCategory;
use App\Modules\Models\Student\Student;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Registration extends Model
{
protected $table = 'tbl_registrations';
use HasFactory;
protected $fillable = [
'campaign_id',
'name',
'email',
'phone',
'address',
'city',
'state',
'zone',
'nearest_landmark',
'preffered_location',
'see_year',
'see_grade',
'headers',
'country_id',
'state_id',
'district_id',
'municipality_name',
'ward_no',
'village_name',
'full_address',
'user_agent',
'see_stream',
'see_school',
'plus2_year',
'plus2_grade',
'plus2_stream',
'plus2_college',
'bachelors_year',
'bachelors_grade',
'bachelors_stream',
'bachelors_college',
'highest_qualification',
'highest_grade',
'highest_stream',
'highest_college',
'preparation_class',
'preparation_score',
'preparation_bandscore',
'preparation_date',
'test_name',
'coupen_code',
'test_score',
'intrested_for_country',
'intrested_course',
'source',
'display_order',
'remarks',
'status',
'created_by',
'created_on',
];
public static function getFollowUp($id)
{
return FollowUp::select('id','next_schedule','follow_up_name','follow_up_by','remarks')->where('follow_up_type','registration')->where('refrence_id',$id)->latest()->first();
}
public static function getFollowUpCount($id)
{
return FollowUp::select('id','next_schedule','follow_up_name','follow_up_by','remarks')->where('follow_up_type','registration')->where('refrence_id',$id)->latest()->get();
}
public function leadcategory()
{
return $this->belongsTo(LeadCategory::class);
}
public function campaign()
{
return $this->belongsTo(Campaign::class);
}
public function enroll($id) {
return Student::select('id')->where('source_ref','registration')->where('ref_id',$id)->latest()->first();
}
}

View File

@ -0,0 +1,49 @@
<?php
namespace App\Modules\Models\Role;
use App\Modules\Models\Permission\Permission;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Role extends Model
{
use HasFactory;
protected $fillable= [
'name', 'slug', 'visibility','status', 'availability','is_deleted',
'deleted_at','created_by','last_updated_by','last_deleted_by'
];
protected $appends = [
'visibility_text', 'status_text', 'availability_text', 'thumbnail_path', 'image_path'
];
public function permissions(){
return $this->belongsToMany(Permission::class,'role_has_permissions');
}
function getVisibilityTextAttribute(){
return ucwords(str_replace('_', ' ', $this->visibility));
}
function getStatusTextAttribute(){
return ucwords(str_replace('_', ' ', $this->status));
}
function getAvailabilityTextAttribute(){
return ucwords(str_replace('_', ' ', $this->availability));
}
function creator(){
return $this->belongsTo(User::class,'created_by');
}
function getImagePathAttribute(){
return $this->path.'/'. $this->image;
}
function getThumbnailPathAttribute(){
return $this->path.'/thumb/'. $this->image;
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\Modules\Models\Setting;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Setting extends Model
{
use HasFactory;
protected $table = 'tbl_settings';
protected $fillable = [
'slug','title', 'value', 'is_active'
];
protected $casts = [
'is_active' => 'boolean'
];
public function scopeFetch($query, $slug)
{
return $query->whereSlug($slug);
}
public function scopeActive($query, $type = true)
{
return $query->whereIsActive($type);
}
}

View File

@ -0,0 +1,32 @@
<?php
namespace App\Modules\Models\State;
use App\Modules\Models\Country\Country;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class State extends Model
{
use HasFactory;
protected $fillable = [
'state_name',
'country_id',
'status',
];
public function country()
{
return $this->belongsTo(Country::class);
}
public static function getStates()
{
return self::select('id','state_name')->where('status','Active')->get();
}
public static function getStatesByCountryId($country_id)
{
return self::select('id','state_name')->where('status','Active')->where('country_id',$country_id)->get();
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace App\Modules\Models\Student;
use App\Modules\Models\Admission\Admission;
use App\Modules\Models\Agent\Agent;
use App\Modules\Models\Country\Country;
use App\Modules\Models\District\District;
use App\Modules\Models\Location\Location;
use App\Modules\Models\State\State;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Student extends Model
{
protected $table = 'tbl_students';
use HasFactory;
protected $fillable = [
'applicant',
'first_name',
'middle_name',
'last_name',
'gender',
'material_status',
'spouse_name',
'father_name',
'mother_name',
'mobile_no',
'alternate_mobile_no',
'email',
'dob',
'country_id',
'state_id',
'source_ref',
'ref_id',
'district_id',
'municipality_name',
'ward_no',
'intake_year',
'intake_month',
'village_name',
'full_address',
'preffered_location',
'intrested_for_country',
'intrested_course',
'status',
'created_by',
'updated_by',
];
public function admission(){
return $this->belongsTo(Admission::class,'id','student_id');
}
public function educations()
{
return $this->hasMany(StudentEducation::class,'student_id','id');
}
public function languages()
{
return $this->hasMany(StudentLanguage::class,'student_id','id');
}
public function fields()
{
return $this->hasMany(StudentField::class,'student_id','id');
}
public function agent(){
return $this->belongsTo(Agent::class,'ref_id','id');
}
public function location(){
return $this->belongsTo(Location::class,'ref_id','id');
}
public function student_country(){
return $this->belongsTo(Country::class,'country_id','id');
}
public function student_state(){
return $this->belongsTo(State::class,'state_id','id');
}
public function student_district(){
return $this->belongsTo(District::class,'district_id','id');
}
}

View File

@ -0,0 +1,37 @@
<?php
namespace App\Modules\Models\Student;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class StudentEducation extends Model
{
use HasFactory;
protected $table = 'tbl_student_education';
protected $fillable = [
'student_id',
'level',
'university',
'percentage',
'documents',
];
public static function getStudents()
{
// $records = DB::table('candidates')->select('id','first_name','middle_name','last_name','gender','material_status','spouse_name','father_name','mother_name','mobile_no','alternate_mobile_no','email','dob','full_address','status','is_active')->get()->toArray();
$records = DB::table('candidates')
->join('candidate_passports','candidate_passports.candidate_id','candidates.id')
->join('countries','countries.id','candidates.country_id')
->join('provinces','provinces.id','candidates.province_id')
->join('districts','districts.id','candidates.district_id')
->join('districts AS cid','cid.id','candidate_passports.citizenship_issue_district')
->select('candidates.id','candidates.first_name','candidates.middle_name','candidates.last_name','candidates.gender','candidates.spouse_name','candidates.father_name','candidates.mother_name','candidates.mobile_no','candidates.alternate_mobile_no','candidates.email','candidates.dob','countries.country_name','provinces.province_name','districts.district_name','candidates.municipality_name','candidates.ward_no','candidates.full_address','candidate_passports.passport_number','candidate_passports.passport_issue_date','candidate_passports.passport_expiry_date','candidate_passports.citizenship_number','candidate_passports.citizenship_issue_date','cid.district_name AS cid_name')
->get()
->toArray();
return $records;
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace App\Modules\Models\Student;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class StudentField extends Model
{
use HasFactory;
protected $fillable = [
'student_id',
'name',
];
}

View File

@ -0,0 +1,19 @@
<?php
namespace App\Modules\Models\Student;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class StudentLanguage extends Model
{
use HasFactory;
protected $table = 'tbl_student_languages';
protected $fillable = [
'student_id',
'language',
'score',
'language_documents',
];
}

View File

@ -0,0 +1,17 @@
<?php
namespace App\Modules\Models\TestPreparation;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class TestPreparation extends Model
{
protected $table = 'tbl_testpreparations';
use HasFactory;
protected $fillable = [
'name',
'description',
'status',
];
}

View File

@ -0,0 +1,56 @@
<?php
namespace App\Modules\Models;
use App\Modules\Models\Location\Location;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Spatie\Permission\Traits\HasRoles;
class User extends Authenticatable
{
use HasFactory, Notifiable, HasRoles;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'email',
'password',
'role',
'status',
'is_deleted',
'deleted_at',
'last_updated_by',
'last_deleted_by'
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
public function location()
{
return $this->belongsTo(Location::class, 'id','user_id')->first();
}
}

View File

@ -0,0 +1,222 @@
<?php
namespace App\Modules\Service\Permission;
use App\Modules\Models\Permission\Permission;
use App\Modules\Service\Service;
use Carbon\Carbon;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Yajra\DataTables\Facades\DataTables;
use Spatie\Permission\Models\Permission as SepPermission;
class PermissionService extends Service
{
protected $Permission;
public function __construct(Permission $Permission)
{
$this->Permission = $Permission;
}
/*For DataTable*/
public function getAllData()
{
$query = $this->Permission->whereIsDeleted('no');
return DataTables::of($query)
->addIndexColumn()
// ->editColumn('brand',function(Permission $Permission) {
// if($Permission->brand->name) {
// return $Permission->brand->name;
// }
// })
// ->editColumn('category',function(Permission $Permission) {
// if($Permission->category->name) {
// return $Permission->category->name;
// }
// })
->editColumn('visibility',function(Permission $Permission) {
if($Permission->visibility == 'visible'){
return '<span class="badge text-bg-info">Visible</span>';
} else {
return '<span class="badge text-bg-danger">In-Visible</span>';
}
})
->editColumn('availability',function(Permission $Permission) {
if($Permission->availability == 'available'){
return '<span class="badge text-bg-info">Available</span>';
} else {
return '<span class="badge text-bg-danger">Un-Available</span>';
}
})
->editColumn('status',function(Permission $Permission) {
if($Permission->status == 'active'){
return '<span class="badge text-bg-info">Active</span>';
} else {
return '<span class="badge text-bg-danger">In-Active</span>';
}
})
->editColumn('image',function(Permission $Permission) {
if(isset($Permission->image_path)){
return '<img src="http://127.0.0.1:8000/'.($Permission->image_path).'" width="100px">';
} else {
;
}
})
->editcolumn('actions',function(Permission $Permission) {
$editRoute = route('permission.edit',$Permission->id);
$deleteRoute = route('permission.destroy',$Permission->id);
return getTableHtml($Permission,'actions',$editRoute,$deleteRoute);
return getTableHtml($Permission,'image');
})->rawColumns(['visibility','availability','status','image'])->make(true);
}
public function create(array $data)
{
try {
/* $data['keywords'] = '"'.$data['keywords'].'"';*/
//dd($data);
// DB::table('permissions')->insert(['guard_name' => 'web']);
$Permission = SepPermission::create($data);
return $Permission;
} catch (Exception $e) {
return null;
}
}
/**
* Paginate all Permission
*
* @param array $filter
* @return Collection
*/
public function paginate(array $filter = [])
{
$filter['limit'] = 25;
return $this->Permission->orderBy('id','DESC')->whereIsDeleted('no')->paginate($filter['limit']);
}
/**
* Get all Permission
*
* @return Collection
*/
public function all()
{
return $this->Permission->whereIsDeleted('no')->all();
}
/**
* Get all Permissions with supervisor type
*
* @return Collection
*/
public function find($PermissionId)
{
try {
return $this->Permission->whereIsDeleted('no')->find($PermissionId);
} catch (Exception $e) {
return null;
}
}
public function update($PermissionId, array $data)
{
try {
$data['last_updated_by']= Auth::user()->id;
$Permission= $this->Permission->find($PermissionId);
$Permission = $Permission->update($data);
//$this->logger->info(' created successfully', $data);
return $Permission;
} catch (Exception $e) {
//$this->logger->error($e->getMessage());
return false;
}
}
/**
* Delete a Permission
*
* @param Id
* @return bool
*/
public function delete($PermissionId)
{
try {
$data['last_deleted_by']= Auth::Permission()->id;
$data['deleted_at']= Carbon::now();
$Permission = $this->Permission->find($PermissionId);
$data['is_deleted']='yes';
return $Permission = $Permission->update($data);
} catch (Exception $e) {
return false;
}
}
/**
* write brief description
* @param $name
* @return mixed
*/
public function getByName($name){
return $this->Permission->whereIsDeleted('no')->whereName($name);
}
public function getBySlug($slug){
return $this->Permission->whereIsDeleted('no')->whereSlug($slug)->first();
}
function uploadFile($file)
{
if (!empty($file)) {
$this->uploadPath = 'uploads/Permission';
return $fileName = $this->uploadFromAjax($file);
}
}
public function __deleteImages($subCat)
{
try {
if (is_file($subCat->image_path))
unlink($subCat->image_path);
if (is_file($subCat->thumbnail_path))
unlink($subCat->thumbnail_path);
} catch (\Exception $e) {
}
}
public function updateImage($PermissionId, array $data)
{
try {
$Permission = $this->Permission->find($PermissionId);
$Permission = $Permission->update($data);
return $Permission;
} catch (Exception $e) {
//$this->logger->error($e->getMessage());
return false;
}
}
public function getPermissionByGroupWise()
{
$groupPermissions = $this->Permission->all();
return $groupPermissions;
}
}

View File

@ -0,0 +1,224 @@
<?php
namespace App\Modules\Service\Role;
use App\Modules\Models\Role\Role;
use App\Modules\Service\Service;
use Carbon\Carbon;
use Illuminate\Support\Facades\Auth;
use Yajra\DataTables\Facades\DataTables;
class RoleService extends Service
{
protected $role;
public function __construct(Role $role)
{
$this->role = $role;
}
/*For DataTable*/
public function getAllData()
{
$query = $this->role->whereIsDeleted('no');
return DataTables::of($query)
->addIndexColumn()
// ->editColumn('brand',function(role $role) {
// if($role->brand->name) {
// return $role->brand->name;
// }
// })
// ->editColumn('role',function(role $role) {
// if($role->role->name) {
// return $role->role->name;
// }
// })
->editColumn('visibility',function(Role $role) {
if($role->visibility == 'visible'){
return '<span class="badge text-bg-info">Visible</span>';
} else {
return '<span class="badge text-bg-danger">In-Visible</span>';
}
})
->editColumn('availability',function(Role $role) {
if($role->availability == 'available'){
return '<span class="badge text-bg-info">Available</span>';
} else {
return '<span class="badge text-bg-danger">Un-Available</span>';
}
})
->editColumn('status',function(Role $role) {
if($role->status == 'active'){
return '<span class="badge text-bg-info">Active</span>';
} else {
return '<span class="badge text-bg-danger">In-Active</span>';
}
})
->editcolumn('actions',function(Role $role) {
$editRoute = route('role.edit',$role->id);
$deleteRoute = route('role.destroy',$role->id);
return getTableHtml($role,'actions',$editRoute,$deleteRoute);
return getTableHtml($role,'image');
})->rawColumns(['visibility','availability','status','image'])->make(true);
}
public function create(array $data)
{
try {
/* $data['keywords'] = '"'.$data['keywords'].'"';*/
$data['visibility'] = (isset($data['visibility']) ? $data['visibility'] : '')=='on' ? 'visible' : 'invisible';
$data['status'] = (isset($data['status']) ? $data['status'] : '')=='on' ? 'active' : 'in_active';
$data['availability'] = (isset($data['availability']) ? $data['availability'] : '')=='on' ? 'available' : 'not_available';
$data['created_by']= Auth::role()->id;
//dd($data);
$role = $this->role->create($data);
return $role;
} catch (Exception $e) {
return null;
}
}
/**
* Paginate all role
*
* @param array $filter
* @return Collection
*/
public function paginate(array $filter = [])
{
$filter['limit'] = 25;
return $this->role->orderBy('id','DESC')->whereIsDeleted('no')->paginate($filter['limit']);
}
/**
* Get all role
*
* @return Collection
*/
public function all()
{
return $this->role->whereIsDeleted('no')->all();
}
/**
* Get all roles with supervisor type
*
* @return Collection
*/
public function find($roleId)
{
try {
return $this->role->whereIsDeleted('no')->find($roleId);
} catch (Exception $e) {
return null;
}
}
public function update($roleId, array $data)
{
try {
$data['visibility'] = (isset($data['visibility']) ? $data['visibility'] : '')=='on' ? 'visible' : 'invisible';
$data['status'] = (isset($data['status']) ? $data['status'] : '')=='on' ? 'active' : 'in_active';
$data['availability'] = (isset($data['availability']) ? $data['availability'] : '')=='on' ? 'available' : 'not_available';
$data['has_subrole'] = (isset($data['has_subrole']) ? $data['has_subrole'] : '')=='on' ? 'yes' : 'no';
$data['last_updated_by']= Auth::role()->id;
$role= $this->role->find($roleId);
$role = $role->update($data);
//$this->logger->info(' created successfully', $data);
return $role;
} catch (Exception $e) {
//$this->logger->error($e->getMessage());
return false;
}
}
/**
* Delete a role
*
* @param Id
* @return bool
*/
public function delete($roleId)
{
try {
$data['last_deleted_by']= Auth::user()->id;
$data['deleted_at']= Carbon::now();
$role = $this->role->find($roleId);
$data['is_deleted']='yes';
return $role = $role->update($data);
} catch (Exception $e) {
return false;
}
}
/**
* write brief description
* @param $name
* @return mixed
*/
public function getByName($name){
return $this->role->whereIsDeleted('no')->whereName($name);
}
public function getBySlug($slug){
return $this->role->whereIsDeleted('no')->whereSlug($slug)->first();
}
public function getAssignedPermission($id){
try{
$role = Role::with('permissions')->find($id);
$per = $role->permissions;
return $per;
}catch (Exception $e){
return false;
}
}
function uploadFile($file)
{
if (!empty($file)) {
$this->uploadPath = 'uploads/role';
return $fileName = $this->uploadFromAjax($file);
}
}
public function __deleteImages($subCat)
{
try {
if (is_file($subCat->image_path))
unlink($subCat->image_path);
if (is_file($subCat->thumbnail_path))
unlink($subCat->thumbnail_path);
} catch (\Exception $e) {
}
}
public function updateImage($roleId, array $data)
{
try {
$role = $this->role->find($roleId);
$role = $role->update($data);
return $role;
} catch (Exception $e) {
//$this->logger->error($e->getMessage());
return false;
}
}
}

View File

@ -0,0 +1,185 @@
<?php
namespace App\Modules\Service;
use Illuminate\Http\UploadedFile;
use Intervention\Image\Facades\Image;
use Symfony\Component\HttpFoundation\File\File;
/**
* Class Service
*
* @package App\Services
*/
abstract class Service
{
protected $uploadPath = '/uploads';
public function upload(UploadedFile $file, $width = 1170, $height = 559)
{
if(!is_dir('uploads'))
mkdir('uploads');
if(!is_dir($this->uploadPath))
mkdir($this->uploadPath);
$destination = $this->uploadPath;
if ($file->isValid()) {
$fileName = $file->getClientOriginalName();
$file_type = $file->getClientOriginalExtension();
$newFileName = sprintf("%s.%s", sha1($fileName . time()), $file_type);
try {
$image = $file->move($destination, $newFileName);
if(substr($file->getClientMimeType(), 0, 5) == 'image')
$this->createThumb($image, $width, $height);
return $image->getFilename();
} catch (Exception $e) {
return $e->getMessage();
$this->logger->error(sprintf('File could not be uploaded : %s', $e->getMessage()));
}
return false;
}
return false;
}
public function uploadFromAjax(UploadedFile $file, $width = 320, $height = 320)
{
if (!is_dir('uploads'))
mkdir('uploads');
if (!is_dir($this->uploadPath))
mkdir($this->uploadPath);
$destination = $this->uploadPath;
if ($file->isValid()) {
$fileName = $file->getClientOriginalName();
$file_type = $file->extension();
$newFileName = sprintf("%s.%s", sha1($fileName . time()), $file_type);
try {
$image = $file->move($destination, $newFileName);
if (substr($file->getClientMimeType(), 0, 5) == 'image')
$this->createThumb($image, $width, $height);
return $image->getFilename();
} catch (Exception $e) {
return $e->getMessage();
}
return false;
}
return false;
}
/**
* Create Image thumb
*
* @param File $image
* @param int $width
* @param int $height
* @return boolean
*/
public function createThumb(File $image, $width = 320, $height = 320)
{
try{
$img = Image::make($image->getPathname());
$img->fit($width, $height);
$path = sprintf('%s/thumb/%s', $image->getPath(), $image->getFilename());
$directory = sprintf('%s/thumb', $image->getPath());
if (!file_exists($directory)) {
mkdir($directory, 0777, true);
}
return $img->save($path);
}catch (\Exception $e){
return '';
}
}
/**
* Delete Image
*
* @param $image
* @return bool
*/
public function deleteImage($image)
{
$path = $this->uploadPath;
try {
$large = $path . '/' . $image;
unlink($large);
$thumb = sprintf('%s/thumb/%s', $path, $image);
unlink($thumb);
return true;
} catch (\Exception $e) {
return false;
}
}
public function deleteMultipleImages($images)
{
$path = $this->uploadPath;
try {
foreach ($images as $image) {
$large = $path . '/' . $image;
unlink($large);
$thumb = sprintf('%s/thumb/%s', $path, $image);
unlink($thumb);
}
return true;
} catch (\Exception $e) {
return false;
}
}
public function uploadExcel($file) {
$destinationPath = base_path() . '/public/uploads';
$fileName = $file->getClientOriginalName();
$file_type = $file->getClientOriginalExtension();
$newFileName = sprintf("%s.%s", sha1($fileName . time()), $file_type);
try {
return $file->move($destinationPath, $newFileName);
} catch (Exception $e) {
$this->logger->error(sprintf('File could not be uploaded : %s', $e->getMessage()));
}
}
public function uploadFile($file) {
$destination = $this->uploadPath;
$fileName = $file->getClientOriginalName();
$file_type = $file->getClientOriginalExtension();
$newFileName = sprintf("%s.%s", sha1($fileName . time()), $file_type);
try {
$file->move($destination, $newFileName);
return $newFileName;
} catch (Exception $e) {
$this->logger->error(sprintf('File could not be uploaded : %s', $e->getMessage()));
}
}
public function deleteFile($file)
{
$path = $this->uploadPath;
try {
$large = $path . '/' . $file;
unlink($large);
return true;
} catch (\Exception $e) {
return false;
}
}
public function generateCode($base = '') {
return sha1($base . rand() . time());
}
}

View File

@ -0,0 +1,272 @@
<?php
namespace App\Modules\Service\User;
use App\Modules\Models\User;
use App\Modules\Service\Service;
use Carbon\Carbon;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Yajra\DataTables\Facades\DataTables;
class UserService extends Service
{
protected $user;
public function __construct(User $user)
{
$this->user = $user;
}
/*For DataTable*/
public function getAllData()
{
$query = $this->user->whereIsDeleted('no');
return DataTables::of($query)
->addIndexColumn()
// ->editColumn('brand',function(user $user) {
// if($user->brand->name) {
// return $user->brand->name;
// }
// })
// ->editColumn('category',function(user $user) {
// if($user->category->name) {
// return $user->category->name;
// }
// })
->editColumn('visibility',function(user $user) {
if($user->visibility == 'visible'){
return '<span class="badge text-bg-info">Visible</span>';
} else {
return '<span class="badge text-bg-danger">In-visible</span>';
}
})
->editColumn('availability',function(user $user) {
if($user->availability == 'available'){
return '<span class="badge text-bg-info">Available</span>';
} else {
return '<span class="badge text-bg-danger">Un-Available</span>';
}
})
->editColumn('status',function(user $user) {
if($user->status == 'active'){
return '<span class="badge text-bg-info">Active</span>';
} else {
return '<span class="badge text-bg-danger">In-Active</span>';
}
})
->editColumn('image',function(user $user) {
if(isset($user->image_path)){
return '<img src="http://127.0.0.1:8000/'.($user->image_path).'" width="100px">';
} else {
;
}
})
->editcolumn('actions',function(user $user) {
$editRoute = route('user.edit',$user->id);
$deleteRoute = route('user.destroy',$user->id);
return getTableHtml($user,'actions',$editRoute,$deleteRoute);
return getTableHtml($user,'image');
})->rawColumns(['visibility','availability','status','image'])->make(true);
}
public function create(array $data)
{
try {
// dd($data);
/* $data['keywords'] = '"'.$data['keywords'].'"';*/
$data['visibility'] = (isset($data['visibility']) ? $data['visibility'] : '')=='on' ? 'visible' : 'invisible';
$data['status'] = (isset($data['status']) ? $data['status'] : '')=='on' ? 'active' : 'in_active';
$data['availability'] = (isset($data['availability']) ? $data['availability'] : '')=='on' ? 'available' : 'not_available';
$data['created_by']= Auth::user()->id;
$data['password'] = Hash::make($data['password']);
//dd($data);
$user = $this->user->create($data);
return $user;
} catch (Exception $e) {
return null;
}
}
/**
* Paginate all User
*
* @param array $filter
* @return Collection
*/
public function paginate(array $filter = [])
{
$filter['limit'] = 25;
return $this->user->orderBy('id','DESC')->whereIsDeleted('no')->paginate($filter['limit']);
}
/**
* Get all User
*
* @return Collection
*/
public function all()
{
return $this->user->whereIsDeleted('no')->all();
}
/**
* Get all users with supervisor type
*
* @return Collection
*/
public function find($userId)
{
try {
return $this->user->whereIsDeleted('no')->find($userId);
} catch (Exception $e) {
return null;
}
}
public function update($userId, array $data)
{
try {
$data['visibility'] = (isset($data['visibility']) ? $data['visibility'] : '')=='on' ? 'visible' : 'invisible';
$data['status'] = (isset($data['status']) ? $data['status'] : '')=='on' ? 'active' : 'in_active';
$data['availability'] = (isset($data['availability']) ? $data['availability'] : '')=='on' ? 'available' : 'not_available';
$data['has_subuser'] = (isset($data['has_subuser']) ? $data['has_subuser'] : '')=='on' ? 'yes' : 'no';
$data['last_updated_by']= Auth::user()->id;
$user= $this->user->find($userId);
$user = $user->update($data);
//$this->logger->info(' created successfully', $data);
return $user;
} catch (Exception $e) {
//$this->logger->error($e->getMessage());
return false;
}
}
/**
* Delete a User
*
* @param Id
* @return bool
*/
public function delete($userId)
{
try {
$data['last_deleted_by']= Auth::user()->id;
$data['deleted_at']= Carbon::now();
$user = $this->user->find($userId);
$data['is_deleted']='yes';
return $user = $user->update($data);
} catch (Exception $e) {
return false;
}
}
public function getUserRoles($id){
try{
$user = User::with('roles')->find($id);
$roles = $user->roles;
return $roles;
}catch (Exception $e){
return false;
}
}
/**
* write brief description
* @param $name
* @return mixed
*/
public function getByName($name){
return $this->user->whereIsDeleted('no')->whereName($name);
}
public function getBySlug($id){
return $this->user->whereIsDeleted('no')->whereId($id)->first();
}
function uploadFile($file)
{
if (!empty($file)) {
$this->uploadPath = 'uploads/user';
return $fileName = $this->uploadFromAjax($file);
}
}
public function __deleteImages($subCat)
{
try {
if (is_file($subCat->image_path))
unlink($subCat->image_path);
if (is_file($subCat->thumbnail_path))
unlink($subCat->thumbnail_path);
} catch (\Exception $e) {
}
}
public function updateImage($userId, array $data)
{
try {
$user = $this->user->find($userId);
$user = $user->update($data);
return $user;
} catch (Exception $e) {
//$this->logger->error($e->getMessage());
return false;
}
}
public function profileUpdate(array $data, $userId)
{
try {
$data['email'] = $data['email'];
$data['password'] = Hash::make($data['password']);
$data['last_updated_by']= Auth::user()->id;
$user= $this->user->find($userId);
$user = $user->update($data);
//$this->logger->info(' created successfully', $data);
return $user;
} catch (Exception $e) {
//$this->logger->error($e->getMessage());
return false;
}
}
public function passwordUpdate(array $data)
{
try {
$user= $this->user->where('email',$data['email'])->first();
if(isset($user)) {
$data['password'] = Hash::make($data['password']);
$user = $user->update($data);
} else {
Toastr()->error('The requested email does not exist','Sorry');
return false;
}
//$this->logger->info(' created successfully', $data);
return true;
} catch (Exception $e) {
//$this->logger->error($e->getMessage());
return false;
}
}
}

View File

@ -0,0 +1,75 @@
<?php
/**
* Created by PhpStorm.
* User: aarrunyal
* Date: 03/01/2019
* Time: 17:53
*/
namespace App\Modules\Service\UserRole;
use App\Modules\Models\Role\PermissionRole;
use App\Modules\Models\User\RoleUser;
class UserRoleService
{
protected $userRole;
protected $rolePermission;
function __construct(
RoleUser $userRoleModel,
PermissionRole $rolePermissionModel
)
{
$this->userRole = $userRoleModel;
$this->rolePermission = $rolePermissionModel;
}
//User role deletion using roleid and userid
public function deleteUserRoleByUserId($id){
try{
$role = $this->userRole->where('user_id', '=', $id)->delete();
return true;
}catch (Exception $e){
return false;
}
}
public function deleteUserRoleByRoleId($id){
try{
$role = $this->userRole->where('role_id', '=', $id)->delete();
return true;
}catch (Exception $e){
return false;
}
}
//permission deletion using roleid and permissionid
public function deleteRolePermissionByPermissionId($id){
try{
$permission = $this->rolePermission->where('permission_id', '=', $id)->delete();
return true;
}catch (Exception $e){
return false;
}
}
public function deleteRolePermissionByRoleId($id){
try{
$permission = $this->rolePermission->where('role_id', '=', $id)->delete();
return true;
}catch (Exception $e){
return false;
}
}
public function getAllUserWithRoleId($roleId){
try{
$users = $this->userRole->where('role_id','=', $roleId)->get();
return $users;
}catch (\Exception $e){
return false;
}
}
}

286
app/Modules/helpers.php Normal file
View File

@ -0,0 +1,286 @@
<?php
use App\Modules\Models\Admission\Admission;
use App\Modules\Models\Campaign\Campaign;
use App\Modules\Models\College\College;
use App\Modules\Models\Country\Country;
use App\Modules\Models\District\District;
use App\Modules\Models\Location\Location;
use App\Modules\Models\Province\Province;
use App\Modules\Models\Setting\Setting;
use App\Modules\Models\State\State;
use App\Modules\Models\User;
use Illuminate\Support\Facades\Storage;
function getTableHtml($object, $type, $editRoute = null, $deleteRoute = null, $printRoute = null, $viewRoute = null,$checklist = null,$billRoute = null, $invoiceRoute = null)
{
switch ($type) {
case 'actions':
return view('general.table-actions', compact('editRoute','deleteRoute','viewRoute','printRoute','checklist','billRoute','invoiceRoute'));
break;
case 'availability':
return '<span class="badge-boxed' . getLabel($object->availability) . '">' . $object->availability_text . '</span>';
break;
case 'visibility':
return '<span class="badge-boxed' . getLabel($object->visibility) . '">' . $object->visibility_text . '</span>';
break;
case 'status':
return '<span class="badge-boxed' . getLabel($object->status) . '">' . $object->status_text . '</span>';
break;
case 'is_main':
return '<span class="badge-boxed' . getLabel($object->is_main) . '">' . $object->main_text . '</span>';
break;
case 'is_default':
return '<span class="badge-boxed' . getLabel($object->is_default) . '">' . $object->main_text . '</span>';
break;
case 'image':
return view('general.lightbox', compact('object'));
break;
}
}
function getLabel($status)
{
$badge = '';
switch ($status) {
case 'yes':
$badge = 'badge-primary';
break;
case 'no':
$badge = 'badge-danger';
break;
case 'available':
$badge = 'badge-success';
break;
case 'not_available':
$badge = 'badge-danger';
break;
case 'visible':
$badge = 'badge-success';
break;
case 'in-visible':
$badge = 'badge-success';
break;
case 'active':
$badge = 'badge-primary';
break;
case 'inactive':
$badge = 'badge-danger';
break;
}
return $badge;
}
/**
* ---------------------------------------------
* | Country |
* ----------------------------------------------
*/
function getCountries()
{
return Country::getCountries();
}
/**
* ---------------------------------------------
* | State |
* ----------------------------------------------
*/
function getStates()
{
return State::getStates();
}
function getStatesByCountryId($country_id)
{
return State::getStatesByCountryId($country_id);
}
/**
* ---------------------------------------------
* | Colleges |
* ----------------------------------------------
*/
function getColleges()
{
return College::getColleges();
}
function getCollegesByStateId($state_id)
{
return College::getCollegesByStateId($state_id);
}
/**
* ---------------------------------------------
* | District |
* ----------------------------------------------
*/
function getDistricts()
{
return District::getDistricts();
}
function getDistrictsByProvinceId($state_id)
{
return District::getDistrictsByProvinceId($state_id);
}
/**
* ---------------------------------------------
* | Commenced |
* ----------------------------------------------
*/
function getCommencedByStudent($student_id)
{
$admission = Admission::where('student_id', $student_id)->whereNotNull('commenced_date')->where('commenced_status','applied')->get();
if(!$admission->isEmpty()) {
return false;
}
return true;
}
function uploadCommonFile($file, $path,$existingPath=null)
{
// dd($file->getClientOriginalExtension());
if ($file) {
if($existingPath){
if (Storage::exists($existingPath)) {
Storage::delete($existingPath);
}
}
// generate a new filename. getClientOriginalExtension() for the file extension
$filename = $path . time() .rand(1,999) .'.' . $file->getClientOriginalExtension();
// save to storage/app/photos as the new $filename
$path = $file->storeAs('student', $filename,'public');
return $path;
}
}
function resizeAndUploadImage($image, $dir, $quality=100, $thumb="" ){
try{
// parameters of resizeAndUploadImage function are image_source, path you want to save image, compression level(0 to 9), resolution("widthxhight")
if(!File::exists($dir)){
File::makeDirectory($dir, 0777, true, true);
}
$getGUID = md5(rand(945976,1232345)."-".time()."-".rand(3456676,3423762)).time();
if($image){
list($width,$height)=getimagesize($image); // get the dimensions of image and assign it to the variables
if($thumb != ""){ //if $thumb is not null
if(strpos($thumb, 'x') !== false){ //if $thumb contains x
list($w,$h) = explode('x', $thumb); //explode x from $thumb and assign the values to $w and $h
} else{
$w = $thumb; // if $thumb doesnot contains x then it must contain width only so assign it to $w variable
}
// list($w,$h) = explode('x', $thumb);
// $w = $thumb;
$ratio = $w/$width; // calculate the ratio of new width to original width
$nwidth = $w; // assign $w to $nwidth
$nheight = $height*$ratio; // calculate new height as constraint proportion and assign it to $nheight
}else{
list($nwidth,$nheight)=getimagesize($image);
}
$newimage=imagecreatetruecolor($nwidth,$nheight); // creates a new blank black colored image with provided width and height
$file_extension = strtolower($image->getClientOriginalExtension()); //get file extension of the given image
if($file_extension == 'jpeg' || $file_extension == 'jpg'){ // if the image is jpeg
$source=imagecreatefromjpeg($image); // assign the image to source image
imagecopyresized($newimage,$source,0,0,0,0,$nwidth,$nheight,$width,$height); // this function will resize the image to new width and height
$image_name = $getGUID.".".$file_extension;
// echo $newimage;
// echo $dir.$image_name;
// echo $quality;
// exit;
$status = imagejpeg($newimage,$dir.$image_name,$quality); // this function will save a jpeg image & return true to status and takes (resized image, destination path to store that image and the quality in range 0-9) as function parameters
}elseif($file_extension == 'png'){
$source=imagecreatefrompng($image);
imagecopyresized($newimage,$source,0,0,0,0,$nwidth,$nheight,$width,$height);
$image_name = $getGUID.".".$file_extension;
$qualityBasedOnPNG = ($quality*9)/100;
$status = imagepng($newimage,$dir.$image_name,$qualityBasedOnPNG);
}elseif($file_extension == 'gif'){
$source=imagecreatefromgif($image);
imagecopyresized($newimage,$source,0,0,0,0,$nwidth,$nheight,$width,$height);
$image_name = $getGUID.".".$file_extension;
$status = imagegif($newimage,$dir.$image_name,$quality);
}else{
$status= false; // the status is false if the image is not saved anyway
}
if($status){
return $image_name; // after successful transaction this will return a image name.
}else{
return 'null'; // otherwise it will return null
}
}else{
return null; // if the request doesnot contain image file it will return null
}
}catch(Exception $e){
return $e->getMessage();
}
}
function removeOldImage($imageName,$folderName){
if (is_file(public_path() . '/uploads/employee/'.$folderName.'/'.$imageName)) {
$imageFile = public_path() . '/uploads/employee/'.$folderName.'/'.$imageName;
unlink($imageFile);
}
}
function removeOldImageByDir($imageName,$dir){
if (is_file(public_path().'/'. $dir.$imageName)) {
$imageFile = public_path().'/'. $dir.$imageName;
unlink($imageFile);
}
}
function getPrimaryNotifiableUsers()
{
$users = User::role('SuperAdmin')->get();
return $users;
}
// SMS CURL
function smsPost($url, $data)
{
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
// Setting Fetch
function setting($query)
{
$setting = Setting::fetch($query)->first();
return $setting ? $setting->value : null;
}
// Campaign List
function getCampaign()
{
return Campaign::all();
}
// Location List
function getLocation()
{
return Location::all();
}