Skip to content

Commit

Permalink
Merge pull request #7 from madhuryadutta/dev
Browse files Browse the repository at this point in the history
PR: Improvements, Features, and Updates
  • Loading branch information
madhuryadutta authored Jan 11, 2025
2 parents 26458ff + 45704f2 commit 4c2a214
Show file tree
Hide file tree
Showing 562 changed files with 653,495 additions and 1,835 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ DISPLAY_S3_ERROR=
DBD_CDN_ENABLE=false
DBD_CDN_ENDPOINT=

ASSET_STORAGE_TYPE=local



QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
Expand Down
91 changes: 91 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Use PHP 8.2 with Apache as base image
FROM php:8.2-apache

# Update package lists and install required dependencies
RUN apt-get update \
&& apt-get install -y git libzip-dev zip unzip libpq-dev \
&& apt-get clean
# RUN apt-get install -y git libzip-dev zip unzip npm

# Install PHP extensions

RUN docker-php-ext-install pdo pdo_mysql pdo_pgsql zip

# Enable Apache modules
RUN a2enmod rewrite \
&& a2enmod headers

# Install Composer globally

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

RUN groupadd -r app -g 1000 && useradd -u 1000 -r -g app -m -d /app -s /sbin/nologin -c "App user" app && \
chmod 755 /var/www/html

RUN php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer

# Set PHP configurations for file uploads

RUN echo "file_uploads = On\n" \
"memory_limit = 500M\n" \
"upload_max_filesize = 500M\n" \
"post_max_size = 500M\n" \
"max_execution_time = 600\n" \
> /usr/local/etc/php/conf.d/uploads.ini

# Set Apache server name

RUN echo 'ServerName 127.0.0.1' >> /etc/apache2/apache2.conf

USER app

# COPY docker/entrypoint.sh /var/www/html/entrypoint.sh
# COPY docker/entrypoint.sh /var/www/html/docker/entrypoint.sh

# Set working directory
WORKDIR /var/www/html

USER root

# Copy application files to the container

COPY . .

# Install production dependencies
RUN composer install --optimize-autoloader --no-dev

# # Install Node.js and npm
RUN curl -sL https://deb.nodesource.com/setup_20.x | bash -
RUN apt-get install -y nodejs
RUN npm install

# Build frontend assets

RUN npm run build

# Adjust permissions for certain directories

RUN chmod o+w ./storage/ -R
RUN chmod o+w ./public/ -R
RUN chmod o+w ./bootstrap/ -R

# Copy Apache configuration files

COPY docker/web/default.conf /etc/apache2/sites-available/000-default.conf
COPY docker/web/default.conf /etc/apache2/sites-enabled/000-default.conf
COPY docker/web/mpm_prefork.conf /etc/apache2/mods-available/mpm_prefork.conf

# Copy the entrypoint script into the container
COPY docker/entrypoint.sh /usr/local/bin/

# Grant execution permissions to the entrypoint script
RUN chmod +x /usr/local/bin/entrypoint.sh

# Expose port 80
EXPOSE 80

# Set the entrypoint to execute the entrypoint script
ENTRYPOINT ["entrypoint.sh"]

# # Start Apache in the foreground
CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: vendor/bin/heroku-php-nginx -C nginx_app.conf /public
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
## About BackEndCMS
# BackEndCMS

BackEndCMS will be a Starter Template for Conetnt Management related web applications based on Laravel framework. I believe developing a Web Application from scratch is time consuming and not must be an enjoyable experience . So Lets work on Minimizng the efforts .

### Project Started on 30/11/2023


## comands to be run on Producton ENvironment
## commands to be run on Producton Environment

```shell
composer install --optimize-autoloader --no-dev
Expand All @@ -16,9 +16,7 @@ php artisan view:cache
```


# Laravel BackEndCMS

## Overview
## Project Overview
Laravel BackEndCMS is a comprehensive content management system (CMS) built on the Laravel framework. It provides a robust backend solution for managing website content efficiently. With its rich feature set and Laravel's powerful capabilities, it offers an intuitive and flexible platform for content creation, organization, and administration.

## Current Features
Expand Down Expand Up @@ -60,4 +58,3 @@ Laravel BackEndCMS is developed and maintained by [Madhurya Dutta](https://githu

## Acknowledgements
Special thanks to all those who have contributed or will contribute to this project..

85 changes: 85 additions & 0 deletions app/Http/Controllers/Api/CategoryController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\Category;
use Illuminate\Http\Request;

class CategoryController extends Controller
{
public function index()
{
$category = Category::all();

return response()->json($category);
}

public function show($id)
{
$category = Category::find($id);

if (! empty($category)) {
return response()->json($category, 200);
} else {
return response()->json(['message' => 'Category Not Found'], 404);
}
}

public function store(Request $request)
{
$category = new Category;
$category->parent_id = $request['parentCategory'];
$category->category_name = $request['categoryName'];
$category->is_active = $request['is_active'];
$category->save();

return response()->json(['message' => 'Category Added'], 201);
}

public function update(Request $request, $id)
{
if (Category::where('id', $id)->exists()) {

$category = Category::find($id);
$category->parent_id = is_null($request['parentCategory']) ? $category->parent_id : $request['parentCategory'];
$category->category_name = is_null($request['categoryName']) ? $category->category_name : $request['categoryName'];
$category->is_active = is_null($request['is_active']) ? $category->is_active : $request['is_active'];
$category->save();

return response()->json(['message' => 'Category Updated'], 200);
} else {
return response()->json(['message' => 'Category Not Found'], 404);
}
}

// Deafult: soft delete
public function destroy($id)
{
if (Category::where('id', $id)->exists()) {
$category = Category::find($id);
$category->is_active = 0;
$category->save();

return response()->json([
'message' => 'category deleted.',
], 202);
} else {
return response()->json(['message' => 'category not found'], 404);
}
}
// Hard Delete

// public function destroy($id)
// {
// if (Category::where('id', $id)->exists()) {
// $category = Category::find($id);
// $category->delete();
// return response()->json([
// "message" => "category deleted."
// ], 202);
// } else {
// return response()->json(['message' => 'category not found'], 404);
// }
// }
}
25 changes: 25 additions & 0 deletions app/Http/Controllers/Api/HealthCheckController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;

class HealthCheckController extends Controller
{
public function check()
{
try {
// Perform any necessary health checks here
// For example, check database connection
DB::connection()->getPdo();

return response()->json(['status' => 'ok']);
} catch (\Exception $e) {
Log::error('Health Check Failed: '.$e->getMessage());

return response()->json(['status' => 'error', 'message' => 'Health check failed.'], 500);
}
}
}
74 changes: 51 additions & 23 deletions app/Http/Controllers/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,76 @@

use App\Models\Category;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;

class CategoryController extends Controller
{
public function viewCategory()
{
$categoryList = DB::select('select * from categories');
return view('categoryList', ['categoryList' => $categoryList]);
// Check if the category list exists in the cache
// if (Cache::has('categoryList')) {
// // If it does, retrieve it from the cache
// $categoryList = Cache::get('categoryList');
// } else {
// If it doesn't, fetch it from the database and store it in the cache
$categoryList = DB::select('select * from categories where is_active = ? or is_active = ?', [1, 0]);
// Cache::put('categoryList', $categoryList, now()->addMinutes(1)); // Cache for 1 minutes
// }

// Return the category list to the view
// return view('categoryList', ['categoryList' => $categoryList]);
return view('category', ['categoryList' => $categoryList]);
}

public function newCategoryForm()
{
$categoryOption = DB::select('select * from categories where is_active = ? ', [1]);

// return view('formCategory', ['categoryList' => $categoryOption]);
return view('categoryEdit', ['categoryList' => $categoryOption]);

}

public function addCategory(Request $request)
{

$category = new Category;
$category->parent_id = $request['parentCategory'];
$category->category_name = $request['categoryName'];
$category->is_active = $request['is_active'];
$category->save();

return redirect()->route('viewCategory');
}

public function addCategory()
public function editCategory(Request $request, $id)
{
$categoryList = DB::select('select * from categories');
$currentCategory = Category::find($id);
$categoryOption = DB::select('select * from categories');

return view('formCategory', ['categoryList' => $categoryList, 'categoryOption' => $categoryOption]);
// return view('formCategoryUpdate', ['categoryList' => $categoryOption, 'currentCategory' => $currentCategory]);
return view('categoryEdit', ['categoryList' => $categoryOption, 'currentCategory' => $currentCategory]);
}

public function editCategory(Request $request, $id = null)
public function updateCategory(Request $request, $id)
{
if ($id == null) {
$category = new Category;
} else {
$customer = Category::find($id);
}
$category = Category::find($id);
$category->parent_id = $request['parentCategory'];
$category->category_name = $request['categoryName'];
$category->is_active = $request['is_active'];
$category->save();

return redirect()->route('viewCategory');
}
// public function edit($id)
// {
// $customer = Category::find($id);
// $data = compact('customer');
// return view('update_customer')->with($data);
// }
// public function destroy($id)
// {
// // echo $id;
// $customer = Customer::where('customer_id', $id)->delete();
// return redirect('customer/view');
// }

public function deleteCategory($id)
{
// "is_active" logic 1 = active , 0 = deactive & 9= delete
$category = Category::find($id);
$category->is_active = 9;
$category->save();

return redirect()->route('viewCategory');
}
}
Loading

0 comments on commit 4c2a214

Please sign in to comment.