Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Nov 11, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
5 changes: 5 additions & 0 deletions Modules/FeaturedProducts/Config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
'name' => 'FeaturedProducts'
];
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

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

class AddFeaturedFieldToProductsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('products', function (Blueprint $table) {
$table->boolean('featured')->default(false);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('products', function (Blueprint $table) {
$table->dropColumn('featured');
});
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Modules\FeaturedProducts\Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;

class FeaturedProductsDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();

// $this->call("OthersTableSeeder");
}
}
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php

namespace Modules\FeaturedProducts\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;

class FeaturedProductsController extends Controller
{
/**
* Display a listing of the resource.
* @return Response
*/
public function index()
{
return view('featuredproducts::index');
}

/**
* Show the form for creating a new resource.
* @return Response
*/
public function create()
{
return view('featuredproducts::create');
}

/**
* Store a newly created resource in storage.
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
//
}

/**
* Show the specified resource.
* @param int $id
* @return Response
*/
public function show($id)
{
return view('featuredproducts::show');
}

/**
* Show the form for editing the specified resource.
* @param int $id
* @return Response
*/
public function edit($id)
{
return view('featuredproducts::edit');
}

/**
* Update the specified resource in storage.
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
//
}

/**
* Remove the specified resource from storage.
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
}
}
Empty file.
Empty file.
22 changes: 22 additions & 0 deletions Modules/FeaturedProducts/Main/FeaturedStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php


namespace Modules\FeaturedProducts\Main;


use App\Product;

class FeaturedStatus
{
public function getFeaturedProducts(){
try{
$cacheMinutes = intval(config('marketplace.front_page_cache.featured_products'));
$featuredProducts = \Cache::remember('featured_products_front_page', $cacheMinutes, function () {
return Product::where('featured',1)->inRandomOrder()->limit(3)->get();
});
} catch (\Exception $e){
$featuredProducts = null;
}
return $featuredProducts;
}
}
Empty file.
114 changes: 114 additions & 0 deletions Modules/FeaturedProducts/Providers/FeaturedProductsServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php

namespace Modules\FeaturedProducts\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Factory;
use Modules\FeaturedProducts\Main\FeaturedStatus;

class FeaturedProductsServiceProvider extends ServiceProvider
{
/**
* Boot the application events.
*
* @return void
*/
public function boot()
{
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
$this->registerFactories();
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
$this->registerFeaturedStatus();
}

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->register(RouteServiceProvider::class);
}

/**
* Register config.
*
* @return void
*/
protected function registerConfig()
{
$this->publishes([
__DIR__.'/../Config/config.php' => config_path('featuredproducts.php'),
], 'config');
$this->mergeConfigFrom(
__DIR__.'/../Config/config.php', 'featuredproducts'
);
}

/**
* Register views.
*
* @return void
*/
public function registerViews()
{
$viewPath = resource_path('views/modules/featuredproducts');

$sourcePath = __DIR__.'/../Resources/views';

$this->publishes([
$sourcePath => $viewPath
],'views');

$this->loadViewsFrom(array_merge(array_map(function ($path) {
return $path . '/modules/featuredproducts';
}, \Config::get('view.paths')), [$sourcePath]), 'featuredproducts');
}

/**
* Register translations.
*
* @return void
*/
public function registerTranslations()
{
$langPath = resource_path('lang/modules/featuredproducts');

if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, 'featuredproducts');
} else {
$this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', 'featuredproducts');
}
}

/**
* Register an additional directory of factories.
*
* @return void
*/
public function registerFactories()
{
if (! app()->environment('production')) {
app(Factory::class)->load(__DIR__ . '/../Database/factories');
}
}

public function registerFeaturedStatus(){
$this->app->bind('FeaturedProductsModule\Status', function ($app) {
return new FeaturedStatus();
});
}

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [];
}
}
69 changes: 69 additions & 0 deletions Modules/FeaturedProducts/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace Modules\FeaturedProducts\Providers;

use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;

class RouteServiceProvider extends ServiceProvider
{
/**
* The module namespace to assume when generating URLs to actions.
*
* @var string
*/
protected $moduleNamespace = 'Modules\FeaturedProducts\Http\Controllers';

/**
* Called before routes are registered.
*
* Register any model bindings or pattern based filters.
*
* @return void
*/
public function boot()
{
parent::boot();
}

/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();

$this->mapWebRoutes();
}

/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->moduleNamespace)
->group(__DIR__ . '/../Routes/web.php');
}

/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->moduleNamespace)
->group(__DIR__ . '/../Routes/api.php');
}
}
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Loading