master crud setup

This commit is contained in:
2024-04-05 11:07:15 +05:45
parent 73b666affc
commit c792d0a7e0
196 changed files with 18017 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',
];
}

25
app/Models/Fee/Fee.php Normal file
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();
}
}

49
app/Models/Role/Role.php Normal file
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',
];
}