Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Create Present
Browse files Browse the repository at this point in the history
* add more functions to create present
  • Loading branch information
lightszentip committed Jan 6, 2022
1 parent ac94c6d commit f69107b
Show file tree
Hide file tree
Showing 19 changed files with 4,918 additions and 78 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ yarn-error.log
/public/js/app.js
package-lock.json
composer.lock
public/files
7 changes: 0 additions & 7 deletions .travis.yml

This file was deleted.

70 changes: 43 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,66 @@
# Presentlist / Geschenkeliste #

## Setup
## Current Version

To create default user and permission
[![GitHub version](https://badge.fury.io/gh/lightszentip%2Fgiftlist.svg)](https://badge.fury.io/gh/lightszentip%2Fgiftlist)

## Installation
### Installation over Release Zip

* unzip
* set www root to public/
* run install_sql.sql on your database
* create .env file in the root dir and set the settings

#### Upgrade

* unzip to new/
* replace all files from new or delete and insert all files from new (exclude .env)
* run:
````shell
php artisan migrate
php artisan db:seed
````

### Setup over repo

* clone the repository
* create .env file in the root dir and set the settings
* ```composer update```
* ```npm install```
* ```npm run dev```
* start with ```php artisan server``` or set your www root to public
* install db with ```php artisan migrate```

http://lightszentip.github.io/giftlist/

[![Build Status](https://travis-ci.org/lightszentip/giftlist.svg?branch=master)](https://travis-ci.org/lightszentip/giftlist)
#### To create default user and permission

````shell
php artisan db:seed
````

#### Upgrade

* git pull
* ```composer update```
* ```npm install```
* ```npm run dev```
````shell
php artisan migrate
php artisan db:seed
````

## Other
http://lightszentip.github.io/giftlist/

=> !! For English => english is under german !!

Presentlist ist eine Geschenkliste auf der man seine Wünsche zur Hochzeit, Geburtstag oder anderen Anlässen auflisten kann. Dabei kann man einen Titel, Beschreibung und auch ein Bild zum Geschnenk angeben, sowie Links zu Händlern oder dem Produkt angeben. Wenn sich dann jemand ein Geschenk von der Liste nimmt, ist es für die anderen nicht mehr sichtbar. Man kann gewählte Geschenke aber auch wieder freigeben und der Administrator sieht nicht wer sich welches Geschenk genommen hat.

![](https://raw.github.com/lightszentip/giftlist/gh-pages/screenshot01.PNG)
![](https://raw.github.com/lightszentip/giftlist/gh-pages/screenshot03.PNG)
![](https://raw.github.com/lightszentip/giftlist/gh-pages/screenshot04.PNG)

## Funktionen ##
- Install Wizard
- Geschenkeliste
- Detail Ansicht von Geschenken
- Geschenk auswählen
Expand Down Expand Up @@ -60,7 +96,6 @@ The app presentlist is show the wishes from wedding, birthday or from other occa


## Functions ##
- Install Wizard
- list with presents
- detail view of present
- use a present
Expand All @@ -77,7 +112,7 @@ The app presentlist is show the wishes from wedding, birthday or from other occa

## Requirements ##

- PHP 5.3.7 or higher
- PHP 7.4 or higher
- MySQL Database (other database only support by you edit the source files)
- PHP PDO Support for MySQL active (extension=php_pdo_mysql.dll)

Expand All @@ -87,22 +122,3 @@ The app presentlist is show the wishes from wedding, birthday or from other occa
Unpack the zip file to the target dir and open the url in your browser. Follow the steps of install wizard. Delete the setup folder and change the password and email address of admin account.

If you have a question, problems or feedback then you can send a mail or create a new issue.

## Verwendete PHP Libraries / Used lbraries: ##

- Rain TPL => [https://github.com/rainphp/raintpl](https://github.com/rainphp/raintpl)
- php-i18n von Philipp Schröer=> [https://github.com/Philipp15b/php-i18n?files=1](https://github.com/Philipp15b/php-i18n?files=1)
- Medoo DB => [http://medoo.in/api/new](http://medoo.in/api/new)
- PHP Setup / Installer Script => [http://www.effiziente-webprogrammierung.info/php-scripts/setup-wizard-installer](http://www.effiziente-webprogrammierung.info/php-scripts/setup-wizard-installer)
- PHP Login von http://www.php-login.net/ => [https://github.com/panique/php-login](https://github.com/panique/php-login) -> Version Advanced
- KLogger von Kenny => [http://codefury.net/projects/klogger/](http://codefury.net/projects/klogger/)
- Kint => [http://raveren.github.io/kint/](http://raveren.github.io/kint/)

## Verwendete JS/HTML/CSS Komponeneten / Used JS/HTML/CSS components: ##

- TableSorter von Christian Bach => [http://mottie.github.io/tablesorter/](https://github.com/Mottie/tablesorter)
- Bootstrap 3.1 => [http://getbootstrap.com/](http://getbootstrap.com/)


[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/lightszentip/giftlist/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

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

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator;

class FileController extends Controller
{
public function uploadFile(Request $request){

$data = array();

$validator = Validator::make($request->all(), [
'file' => 'required|mimes:png,jpg,jpeg,pdf|max:2048'
]);

if ($validator->fails()) {

$data['success'] = 0;
$data['error'] = $validator->errors()->first('file');// Error response

}else{
try {
if($request->file('file')) {

$file = $request->file('file');
$filename = time().'_'.$file->getClientOriginalName();
$filename = hash('sha256', $filename).'.'.$request->file('file')->getClientOriginalExtension();
// File upload location
$location = 'files';

// Upload file
$file->move($location,$filename);

// Response
$data['success'] = 1;
$data['message'] = 'Uploaded Successfully!';
$data['link'] = $filename;

}else{
// Response
$data['success'] = 0;
$data['message'] = 'File not uploaded.';
}
} catch (\Exception $e) {
Log::warning('File upload ',$e);
$data['success'] = 0;
$data['message'] = 'File not uploaded.';
}

}

return response()->json($data);
}
}
25 changes: 21 additions & 4 deletions app/Http/Controllers/PresentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers;

use App\Http\Requests\FormCreatePresentRequest;
use App\Models\PresentLinks;
use App\Models\Presents;
use Illuminate\Http\Request;

Expand All @@ -22,14 +23,30 @@ public function createPresent(Request $request) {
if(empty($user) || !$user->hasPermissionTo('createPresent')) {
abort(403,'no permission');
}
return view('presents-create');
return view('presents-create',['present' => new Presents()]);
}


public function storePresent(FormCreatePresentRequest $request) {
$present = new Presents($request->all());
$present->save();
$links = $request->input('links');

$present = Presents::withoutEvents(function () use ($request,$links) {
$present = new Presents($request->all());
$present->save();
if(!empty($links)) {
$newLinks = array();
foreach ($links as $link) {
if(!is_null($link)) {
$saveLink = new PresentLinks(['link'=>$link,'presents_id'=>$present->id]);
$saveLink->save();
}
}

}
$present->save();
return $present;
});
return redirect()->route('presents.show')
->with('success','Present was created successfully.');
->with('success',__('presents.create_success',['title'=>$present->title, 'id'=> $present->id]));
}
}
12 changes: 12 additions & 0 deletions app/Models/PresentLinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ class PresentLinks extends Model
{
use HasFactory;

/**
* {@inheritdoc}
*/
protected $guarded = [
'id', 'created_at', 'updated_at',
];

public function __construct(array $attributes = array())
{
parent::__construct($attributes);
}

public function present()
{
return $this->belongsTo(Presents::class);
Expand Down
7 changes: 7 additions & 0 deletions app/Models/Presents.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ class Presents extends Model
{
use HasFactory;

/**
* Handle events after all transactions are committed.
*
* @var bool
*/
public $afterCommit = true;

public function links()
{
return $this->hasMany(PresentLinks::class);
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"sass-loader": "^12.4.0"
},
"dependencies": {
"dropzone": "^5.9.3",
"holderjs": "^2.9.9",
"light-switch-bootstrap": "^0.1.3"
}
}
Loading

0 comments on commit f69107b

Please sign in to comment.