update,
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use PHPUnit\Framework\Constraint\Count;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
use App\Models\State;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
|
||||
class Country extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
protected $table = "country";
|
||||
|
||||
public static function getCountryList($request)
|
||||
{
|
||||
|
||||
if ($request->ajax()) {
|
||||
$data = Country::orderBy('id','desc');
|
||||
return DataTables::of($data)
|
||||
->addColumn('action', function ($row) {
|
||||
$actionBtn = '<a href="' . route("admin.country.edit", $row->id) . '" class="edit btn btn-success btn-flat btn-sm"><i class="fa fa-pencil-square-o"></i> </a> <a href="javascript:void(0)" class="delete btn btn-danger btn-flat btn-sm delete_counntry" data-id="' . $row->id . '" ><i class="fa-sharp fa-solid fa fa-trash"></i></a>';
|
||||
return $actionBtn;
|
||||
})
|
||||
->rawColumns(['action'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
/* Add Edit Country */
|
||||
public static function addEditCountry($request, $id = '')
|
||||
{
|
||||
if ($id) {
|
||||
$data = Country::find($id);
|
||||
} else {
|
||||
$data = new Country();
|
||||
}
|
||||
$data->name = $request->name;
|
||||
$data->save();
|
||||
return $data;
|
||||
}
|
||||
|
||||
/* Delete Country */
|
||||
public static function countrydelete($id)
|
||||
{
|
||||
Country::where('id', $id)->delete();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Get Country List */
|
||||
public static function get_CountryList()
|
||||
{
|
||||
return Country::all();
|
||||
}
|
||||
}
|
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
use App\Models\Country;
|
||||
use App\Models\State;
|
||||
use App\Models\ExamCategory;
|
||||
|
||||
class Exam extends Model {
|
||||
|
||||
use HasFactory,
|
||||
SoftDeletes;
|
||||
|
||||
protected $table = 'exam';
|
||||
|
||||
public function getCountry() {
|
||||
return $this->hasOne(Country::class, 'id', 'country_id');
|
||||
}
|
||||
|
||||
public function getState() {
|
||||
return $this->hasOne(State::class, 'id', 'state_id');
|
||||
}
|
||||
|
||||
public function getExamCategory() {
|
||||
return $this->hasOne(ExamCategory::class, 'id', 'exam_category_id');
|
||||
}
|
||||
|
||||
public static function getExamList($request) {
|
||||
if ($request->ajax()) {
|
||||
$data = Exam::with(['getCountry', 'getState', 'getExamCategory']);
|
||||
if ($request->order) {
|
||||
$data->orderBy('id', 'desc');
|
||||
}
|
||||
return DataTables::of($data)
|
||||
->addColumn('country', function ($row) {
|
||||
return $row->getCountry->name;
|
||||
})
|
||||
->addColumn('state', function ($row) {
|
||||
return $row->getState->name;
|
||||
})
|
||||
->addColumn('category', function ($row) {
|
||||
return $row->getExamCategory->title;
|
||||
})
|
||||
->addColumn('action', function ($row) {
|
||||
$actionBtn = '<a href="' . route('admin.exam.edit', $row->id) . '" class="edit btn btn-success btn-flat btn-sm"><i class="fa fa-pencil-square-o"></i> </a> <a href="javascript:void(0)" class="delete btn btn-danger btn-flat btn-sm delete_exam" data-id="' . $row->id . '" ><i class="fa-sharp fa-solid fa fa-trash"></i></a>';
|
||||
return $actionBtn;
|
||||
})
|
||||
->rawColumns(['action'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
|
||||
/* Add Edit Country */
|
||||
|
||||
public static function addEditExam($request, $id = '') {
|
||||
if ($id) {
|
||||
$data = Exam::find($id);
|
||||
} else {
|
||||
$data = new Exam();
|
||||
}
|
||||
$data->exam_category_id = $request->examcategory;
|
||||
$data->country_id = $request->country;
|
||||
$data->state_id = $request->state;
|
||||
$data->name = $request->name;
|
||||
$data->description = $request->description;
|
||||
$data->save();
|
||||
return $data;
|
||||
}
|
||||
|
||||
/* Delete Exam */
|
||||
|
||||
public static function Examdelete($id) {
|
||||
Exam::where('id', $id)->delete();
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
use App\Models\Exam;
|
||||
|
||||
class ExamCategory extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
protected $table = "exam_category";
|
||||
public static function getExamCategoryList($request)
|
||||
{
|
||||
if ($request->ajax()) {
|
||||
$data = ExamCategory::orderBy('id', 'desc');
|
||||
return DataTables::of($data)
|
||||
->addColumn('action', function ($row) {
|
||||
$actionBtn = '<a href="' . route('admin.examcategory.edit', $row->id) . '" class="edit btn btn-success btn-flat btn-sm"><i class="fa fa-pencil-square-o"></i> </a> <a href="javascript:void(0)" class="delete btn btn-danger btn-flat btn-sm delete_examcategory" data-id="' . $row->id . '" ><i class="fa-sharp fa-solid fa fa-trash"></i></a>';
|
||||
return $actionBtn;
|
||||
})
|
||||
->rawColumns(['action'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
/* Add Edit Country */
|
||||
public static function addEditExamCategory($request, $id = '')
|
||||
{
|
||||
if ($id) {
|
||||
$data = ExamCategory::find($id);
|
||||
} else {
|
||||
$data = new ExamCategory();
|
||||
}
|
||||
$data->title = $request->title;
|
||||
$data->save();
|
||||
return $data;
|
||||
}
|
||||
|
||||
/* Delete Country */
|
||||
public static function ExamCategorydelete($id)
|
||||
{
|
||||
ExamCategory::where('id', $id)->delete();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Exam Category */
|
||||
public static function get_ExamCategoryList()
|
||||
{
|
||||
return ExamCategory::all();
|
||||
}
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App\Models\Exam;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
use App\Helper\Helpers;
|
||||
|
||||
class Plan extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
protected $table = 'plans';
|
||||
|
||||
public function getExam(){
|
||||
return $this->hasOne(Exam::class,'id','exam_id');
|
||||
}
|
||||
public static function getPlanList($request)
|
||||
{
|
||||
if ($request->ajax()) {
|
||||
$data = Plan::with(['getExam']);
|
||||
if($request->order){
|
||||
$data->orderBy('id','desc');
|
||||
}
|
||||
return DataTables::of($data)
|
||||
->addColumn('exam', function ($row) {
|
||||
return $row->getExam->name;
|
||||
})
|
||||
->addColumn('unlimited_test_attempt', function ($row) {
|
||||
return Helpers::getunlimitedTestAttempt($row->unlimited_test_attempt);
|
||||
})
|
||||
->addColumn('action', function ($row) {
|
||||
$actionBtn = '<a href="' . route('admin.plan.edit', $row->id) . '" class="edit btn btn-success btn-flat btn-sm"><i class="fa fa-pencil-square-o"></i> </a> <a href="javascript:void(0)" class="delete btn btn-danger btn-flat btn-sm delete_plan" data-id="' . $row->id . '" ><i class="fa-sharp fa-solid fa fa-trash"></i></a>';
|
||||
return $actionBtn;
|
||||
})
|
||||
->rawColumns(['unlimited_test_attempt','action'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
/* Add Edit Plan */
|
||||
public static function addEditPlan($request, $id = '')
|
||||
{
|
||||
if ($id) {
|
||||
$data = Plan::find($id);
|
||||
} else {
|
||||
$data = new Plan();
|
||||
}
|
||||
$data->exam_id = $request->exam;
|
||||
$data->name = $request->name;
|
||||
$data->year = $request->year;
|
||||
$data->price = $request->price ;
|
||||
$data->validity = $request->validity;
|
||||
$data->unlimited_test_attempt = $request->unlimited_test_attempt;
|
||||
$data->attempt = ($request->unlimited_test_attempt == 0) ? $request->attempt : null;
|
||||
$data->description = $request->description;
|
||||
$data->save();
|
||||
return $data;
|
||||
}
|
||||
|
||||
/* Delete Plan */
|
||||
public static function Plandelete($id)
|
||||
{
|
||||
return Plan::where('id', $id)->delete();
|
||||
}
|
||||
|
||||
/* Get Plan List */
|
||||
public static function get_PlanList()
|
||||
{
|
||||
return Plan::all();
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ResetPassword extends Model {
|
||||
|
||||
use HasFactory;
|
||||
|
||||
protected $table = "password_resets";
|
||||
protected $fillable = ['email', 'token'];
|
||||
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use PHPUnit\Framework\Constraint\Count;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class State extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
protected $table = 'state';
|
||||
|
||||
public function getCountry()
|
||||
{
|
||||
return $this->hasOne(Country::class, 'id', 'country_id');
|
||||
}
|
||||
public static function getStateList($request)
|
||||
{
|
||||
if ($request->ajax()) {
|
||||
$data = State::with('getCountry');
|
||||
$data->orderBy('id','desc');
|
||||
return DataTables::of($data)
|
||||
->addColumn('country', function ($row) {
|
||||
return $row->getCountry->name;
|
||||
})
|
||||
->addColumn('action', function ($row) {
|
||||
$actionBtn = '<a href="' . route('admin.state.edit', $row->id) . '" class="edit btn btn-success btn-flat btn-sm"><i class="fa fa-pencil-square-o"></i> </a> <a href="javascript:void(0)" class="delete btn btn-danger btn-sm btn-flat delete_state" data-id="' . $row->id . '" ><i class=" fa-sharp fa-solid fa fa-trash"></i></a>';
|
||||
return $actionBtn;
|
||||
})
|
||||
->rawColumns(['action'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
/* Add Edit State */
|
||||
public static function addEditState($request, $id = '')
|
||||
{
|
||||
if ($id) {
|
||||
$data = State::find($id);
|
||||
} else {
|
||||
$data = new State();
|
||||
}
|
||||
$data->country_id = $request->country;
|
||||
$data->name = $request->name;
|
||||
$data->save();
|
||||
return $data;
|
||||
}
|
||||
|
||||
/* Delete State */
|
||||
public static function Statedelete($id)
|
||||
{
|
||||
return State::where('id', $id)->delete();
|
||||
}
|
||||
|
||||
/* Get State List */
|
||||
public static function get_StateList($country='')
|
||||
{
|
||||
return State::where('country_id', $country)->get();
|
||||
}
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App\Models\Plan;
|
||||
|
||||
class Subject extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
protected $table = 'subjects';
|
||||
|
||||
public function getPlan()
|
||||
{
|
||||
return $this->hasOne(Plan::class, 'id', 'plan_id');
|
||||
}
|
||||
public static function getSubjectList($request)
|
||||
{
|
||||
if ($request->ajax()) {
|
||||
$data = Subject::with('getPlan');
|
||||
$data->orderBy('id', 'desc');
|
||||
return DataTables::of($data)
|
||||
->addColumn('plan', function ($row) {
|
||||
return $row->getPlan->name;
|
||||
})
|
||||
->addColumn('action', function ($row) {
|
||||
$actionBtn = '<a href="' . route('admin.subject.edit', $row->id) . '" class="edit btn btn-success btn-flat btn-sm"><i class="fa fa-pencil-square-o"></i> </a> <a href="javascript:void(0)" class="delete btn btn-danger btn-sm btn-flat delete_subject" data-id="' . $row->id . '" ><i class=" fa-sharp fa-solid fa fa-trash"></i></a>';
|
||||
return $actionBtn;
|
||||
})
|
||||
->rawColumns(['action'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
/* Add Edit State */
|
||||
public static function addEditSubject($request, $id = '')
|
||||
{
|
||||
if ($id) {
|
||||
$data = Subject::find($id);
|
||||
} else {
|
||||
$data = new Subject();
|
||||
}
|
||||
$data->plan_id = $request->plan;
|
||||
$data->name = $request->name;
|
||||
$data->save();
|
||||
return $data;
|
||||
}
|
||||
|
||||
/* Delete State */
|
||||
public static function Subjectdelete($id)
|
||||
{
|
||||
return Subject::where('id', $id)->delete();
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use App\Models\Subject;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class Test extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
protected $table = 'test';
|
||||
public function getSubject()
|
||||
{
|
||||
return $this->hasOne(Subject::class, 'id', 'subject_id');
|
||||
}
|
||||
public static function getTestList($request)
|
||||
{
|
||||
|
||||
if ($request->ajax()) {
|
||||
$data = Test::with('getSubject');
|
||||
if ($request->order) {
|
||||
$data->orderBy('id', 'desc');
|
||||
}
|
||||
return DataTables::of($data)
|
||||
->addColumn('subject', function ($row) {
|
||||
return $row->getSubject->name;
|
||||
})
|
||||
->addColumn('action', function ($row) {
|
||||
$actionBtn = '<a href="' . route("admin.test.edit", $row->id) . '" class="edit btn btn-success btn-flat btn-sm"><i class="fa fa-pencil-square-o"></i> </a> <a href="javascript:void(0)" class="delete btn btn-danger btn-flat btn-sm delete_test" data-id="' . $row->id . '" ><i class="fa-sharp fa-solid fa fa-trash"></i></a>';
|
||||
return $actionBtn;
|
||||
})
|
||||
->rawColumns(['action'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
/* Add Edit Test */
|
||||
public static function addEditTest($request, $id = '')
|
||||
{
|
||||
if ($id) {
|
||||
$data = Test::find($id);
|
||||
} else {
|
||||
$data = new Test();
|
||||
}
|
||||
$data->subject_id = $request->subject;
|
||||
$data->name = $request->name;
|
||||
$data->description = $request->description;
|
||||
$data->save();
|
||||
return $data;
|
||||
}
|
||||
|
||||
/* Delete Country */
|
||||
public static function testdelete($id)
|
||||
{
|
||||
Test::where('id', $id)->delete();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Get Subject List */
|
||||
public static function get_SubjectList()
|
||||
{
|
||||
return Subject::all();
|
||||
}
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\Test;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class TestQuestion extends Model
|
||||
{
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $table = 'test_question';
|
||||
|
||||
public function getTest()
|
||||
{
|
||||
return $this->hasOne(Test::class, 'id', 'test_id');
|
||||
}
|
||||
|
||||
/* Get Question List*/
|
||||
public static function getQuestionList($request)
|
||||
{
|
||||
if ($request->ajax()) {
|
||||
$data = TestQuestion::with('getTest');
|
||||
$data->orderBy('id','desc');
|
||||
return DataTables::of($data)
|
||||
->addColumn('test', function ($row) {
|
||||
return $row->getTest->name;
|
||||
})
|
||||
->addColumn('action', function ($row) {
|
||||
$actionBtn = '<a href="' . route('admin.question.show', $row->id) . '" class="edit btn btn-primary btn-flat btn-sm"><i class="fa fa-eye"></i> </a> <a href="' . route('admin.question.edit', $row->id) . '" class="edit btn btn-success btn-flat btn-sm"><i class="fa fa-pencil-square-o"></i> </a> <a href="javascript:void(0)" class="delete btn btn-danger btn-sm btn-flat delete_question" data-id="' . $row->id . '" ><i class=" fa-sharp fa-solid fa fa-trash"></i></a>';
|
||||
return $actionBtn;
|
||||
})
|
||||
->rawColumns(['action'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
/* Add Edit Question */
|
||||
public static function addEditTestQuestion($request, $id = ''){
|
||||
if ($id) {
|
||||
$data = TestQuestion::find($id);
|
||||
} else {
|
||||
$data = new TestQuestion();
|
||||
}
|
||||
$data->test_id = $request->test;
|
||||
$data->question = $request->question;
|
||||
$data->option_1 = $request->option_1;
|
||||
$data->option_2 = $request->option_2;
|
||||
$data->option_3 = $request->option_3;
|
||||
$data->option_4 = $request->option_4;
|
||||
$data->true_answer = $request->true_answer;
|
||||
$data->solution = $request->solution;
|
||||
|
||||
$data->save();
|
||||
return $data;
|
||||
}
|
||||
|
||||
/* Delete State */
|
||||
public static function Statedelete($id){
|
||||
return TestQuestion::where('id', $id)->delete();
|
||||
}
|
||||
|
||||
/* Get Test List */
|
||||
public static function get_TestList(){
|
||||
return Test::all();
|
||||
}
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class User extends Authenticatable {
|
||||
|
||||
use HasApiTokens,
|
||||
HasFactory,
|
||||
Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for serialization.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
public static function updateProfile($request, $id) {
|
||||
$user = User::find($id);
|
||||
$user->name = $request->name;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
public static function updatePassword($request, $id) {
|
||||
$user = User::find($id);
|
||||
$user->password = Hash::make($request->newpassword);
|
||||
$user->save();
|
||||
}
|
||||
|
||||
/* Student Register */
|
||||
public static function register($request)
|
||||
{
|
||||
$data = new User();
|
||||
|
||||
$data->name = $request->name;
|
||||
$data->email = $request->email;
|
||||
$data->password = Hash::make($request->password);
|
||||
$data->role = config('const.studentRole');
|
||||
$data->save();
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user