Skip to content

Commit

Permalink
Workshop modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
perisicnikola37 committed Jul 28, 2023
1 parent d450ab6 commit 25ae747
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 26 deletions.
4 changes: 3 additions & 1 deletion app/Http/Controllers/CourseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers;

use App\Models\Course;
use App\Models\GlobalVariable;
use Illuminate\Http\Request;

class CourseController extends Controller
Expand All @@ -12,7 +13,8 @@ class CourseController extends Controller
*/
public function index()
{
$courses = Course::with('category', 'instructor', 'level', 'status', 'language')->paginate(5);
$paginationValue = GlobalVariable::where('name', 'pagination')->value('value');
$courses = Course::with('category', 'instructor', 'level', 'status', 'language')->paginate($paginationValue);

return view('pages.Courses.index', compact('courses'));
}
Expand Down
12 changes: 12 additions & 0 deletions app/Models/GlobalVariable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class GlobalVariable extends Model
{
use HasFactory;
protected $guarded = [];
}
47 changes: 24 additions & 23 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function up()
$table->string('town', 255)->nullable();
$table->string('country', 255)->nullable();
$table->string('short_bio', 255)->default('Lorem ipsum');
$table->rememberToken();
// Indexes
$table->index('email');
// Timestamps
Expand Down
34 changes: 34 additions & 0 deletions database/migrations/2023_07_28_074844_global_variables.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('global_variables', function (Blueprint $table) {
$table->id();
$table->string('name', 255);
$table->integer('value');
});

DB::table('global_variables')->insert([
'name' => "pagination",
'value' => 5
]);
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('global_variables');
}
};
4 changes: 2 additions & 2 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

Route::get('/activate/{token}', [AuthenticationAPIController::class, 'activateAccount'])->name('activate');

Route::prefix('admin/dashboard')->middleware('auth')->group(function () {
Route::group(['prefix' => 'admin/dashboard', 'as' => 'web.'], function () {
Route::get('/', [DashboardController::class, 'index'])->name('admin-dashboard');

Route::resource('course', CourseController::class);
Route::resource('courses', CourseController::class);
Route::resource('type', TypeController::class);
Route::resource('language', LanguageController::class);
Route::resource('currency', CurrencyController::class);
Expand Down

0 comments on commit 25ae747

Please sign in to comment.