Bug fixes
This commit is contained in:
parent
861c2cd30c
commit
2041fed921
|
|
@ -36,7 +36,7 @@ class PBXController extends Controller
|
||||||
$data = $request->all();
|
$data = $request->all();
|
||||||
$criteria = $data['search'];
|
$criteria = $data['search'];
|
||||||
|
|
||||||
$pins = pbx_pin::where('name', 'LIKE', '%'.$criteria.'%')
|
$pins = PBXPin::where('name', 'LIKE', '%'.$criteria.'%')
|
||||||
->orWhere('pin', '=', $criteria)
|
->orWhere('pin', '=', $criteria)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
|
@ -61,7 +61,6 @@ class PBXController extends Controller
|
||||||
$user_check = DB::table('pbx_pin')->where('email', '=', $data['add-pbx'])->get();
|
$user_check = DB::table('pbx_pin')->where('email', '=', $data['add-pbx'])->get();
|
||||||
|
|
||||||
if($user_check->isEmpty()){
|
if($user_check->isEmpty()){
|
||||||
|
|
||||||
$check = 0;
|
$check = 0;
|
||||||
while ($check == 0) {
|
while ($check == 0) {
|
||||||
$pinGenerator = rand(10000,99999);
|
$pinGenerator = rand(10000,99999);
|
||||||
|
|
@ -74,13 +73,14 @@ class PBXController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
$pbx = new PBXPin();
|
$pbx = new PBXPin();
|
||||||
|
|
||||||
$pbx->name = $user_check[0]->name;
|
$pbx->name = $user[0]->name;
|
||||||
$pbx->email = $user_check[0]->email;
|
$pbx->email = $user[0]->email;
|
||||||
$pbx->updated_by = $curr_user[0]['name'];
|
$pbx->updated_by = $curr_user[0]['name'];
|
||||||
$pbx->pin = $pinGenerator;
|
$pbx->pin = $pinGenerator;
|
||||||
|
|
||||||
$pbx->save();
|
$pbx->save();
|
||||||
|
return redirect()->route('pbx');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// User already has PBX pin assigned
|
// User already has PBX pin assigned
|
||||||
|
|
@ -115,9 +115,21 @@ class PBXController extends Controller
|
||||||
|
|
||||||
public function disable (Request $request, $id) {
|
public function disable (Request $request, $id) {
|
||||||
try {
|
try {
|
||||||
$pin = DB::table('pbx_pin')->where('id', $id)->delete();
|
$pin = DB::table('pbx_pin')->where('id', $id)->first();
|
||||||
$curr_user = $request->session()->get('credentials');
|
$curr_user = $request->session()->get('credentials');
|
||||||
|
|
||||||
|
$old_pin = new ExpiredPin();
|
||||||
|
|
||||||
|
$old_pin->pin = $pin->pin;
|
||||||
|
$old_pin->name = $pin->name;
|
||||||
|
$old_pin->email = $pin->email;
|
||||||
|
$old_pin->updated_by = $curr_user[0]['name'];
|
||||||
|
|
||||||
|
$old_pin->save();
|
||||||
|
|
||||||
|
$pin = DB::table('pbx_pin')->where('id', $id)->delete();
|
||||||
$pins = DB::table('pbx_pin')->orderBy("name")->get();
|
$pins = DB::table('pbx_pin')->orderBy("name")->get();
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'pins' => $pins,
|
'pins' => $pins,
|
||||||
'curr_user' => $curr_user[0]['name']
|
'curr_user' => $curr_user[0]['name']
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,8 @@ class CreatePBXPinsTable extends Migration
|
||||||
Schema::create('pbx_pins', function (Blueprint $table) {
|
Schema::create('pbx_pins', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->integer("pin");
|
$table->integer("pin");
|
||||||
$table->string("owner");
|
$table->string("name");
|
||||||
|
$table->string("email");
|
||||||
$table->string("updated_by");
|
$table->string("updated_by");
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
35
database/migrations/2023_05_25_155432_expiredpins.php
Normal file
35
database/migrations/2023_05_25_155432_expiredpins.php
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class ExpiredPins extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('expired_pins', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->integer("pin");
|
||||||
|
$table->string("name");
|
||||||
|
$table->string("email");
|
||||||
|
$table->string("updated_by");
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('pbx_pins');
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue