Skip to content
Open

2-ui #65

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
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2
46 changes: 46 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
* text=auto
*.css linguist-vendored
*.scss linguist-vendored
*.js linguist-vendored
CHANGELOG.md export-ignore
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
13 changes: 13 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
php:
preset: laravel
disabled:
- unused_use
finder:
not-name:
- index.php
- server.php
js:
finder:
not-name:
- webpack.mix.js
css: true
41 changes: 41 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
//
];

/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')->hourly();
}

/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');

require base_path('routes/console.php');
}
}
39 changes: 39 additions & 0 deletions app/Event.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
use Ramsey\Uuid\Uuid as Generator;


class Event extends Model
{
use SoftDeletes;
protected $table = "events";
protected $fillable = [
'id',
'name',
'slug',
'startAt',
'endAt'
];
protected $dates = ['deleted_at'];
protected $casts = [
'id' => 'string'
];
protected static function boot()
{
parent::boot();

static::creating(function ($model) {
try {
$model->id = Generator::uuid4()->toString();
} catch (UnsatisfiedDependencyException $e) {
abort(500, $e->getMessage());
}
});
}

}
55 changes: 55 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace App\Exceptions;

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;

class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
* @var array
*/
protected $dontReport = [
//
];

/**
* A list of the inputs that are never flashed for validation exceptions.
*
* @var array
*/
protected $dontFlash = [
'password',
'password_confirmation',
];

/**
* Report or log an exception.
*
* @param \Throwable $exception
* @return void
*
* @throws \Exception
*/
public function report(Throwable $exception)
{
parent::report($exception);
}

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Throwable $exception
* @return \Symfony\Component\HttpFoundation\Response
*
* @throws \Throwable
*/
public function render($request, Throwable $exception)
{
return parent::render($request, $exception);
}
}
13 changes: 13 additions & 0 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}
150 changes: 150 additions & 0 deletions app/Http/Controllers/EventsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Illuminate\Database\QueryException;
use App\Event;
use Response;
use DataTables;

class EventsController extends Controller
{
//VIEW
public function events()
{
return view('events/index');
}

public function create()
{
return view('events/create');
}

public function edit($id)
{
$events = Event::find($id);

return view('events/edit', compact('events'));
}

public function view($id)
{
$events = Event::find($id);

return view('events/view', compact('events'));
}

public function delete($id)
{
$events = Event::findOrFail($id);
$events->delete();

$notification = array(
'message' => 'Delete Success.',
'alert-type' => 'success'
);

return redirect()->to('/events')->with($notification);
}


///API
public function index()
{
$events = Event::all();
return Datatables::of($events)
->addIndexColumn()
->addColumn('action', function($row){

$btn = '
<a href="/events/'.$row->id.'" data-id="'.$row->id.'" title="View" id="viewdata" class="view btn btn-success btn-sm">View</a>
<a href="/events/'.$row->id.'/edit" data-id="'.$row->id.'" title="Edit" id="editdata" class="edit btn btn-warning btn-sm">Edit</a>
<a href="/events/'.$row->id.'/delete" data-id="'.$row->id.'" onclick="deleteFunc()" title="Delete" id="delete" class="delete btn btn-danger btn-sm">Delete</a>
';

return $btn;
})
->rawColumns(['action'])
->make(true);

return response()->json(['success'=> true, 'message'=>'All Event', 'data'=> $events]);
}

public function show($id)
{
$events = Event::find($id);

return response()->json(['success'=> true, 'message'=>'Get one event', 'data'=> $events]);
}


public function save(Request $request)
{
$validator = Validator::make($request->all(), [
'name' => 'required|string',
'slug' => 'required|string|unique:events',
'startAt' => 'required|date',
'endAt' => 'required|date'
]);


if($validator->fails()){
$notification = array(
'message' => $validator->errors(),
'alert-type' => 'error'
);
return redirect()->back()->with($notification);
}

$events = Event::create($request->all());

$notification = array(
'message' => 'Event created.',
'alert-type' => 'success'
);

return redirect()->to('/events')->with($notification);
}


public function update(Request $request, $id)
{
$validator = Validator::make($request->all(), [
'name' => 'string',
'slug' => 'string|unique:events',
'startAt' => 'required|date',
'endAt' => 'required|date'
]);


if($validator->fails()){
$notification = array(
'message' => $validator->errors(),
'alert-type' => 'error'
);
return redirect()->back()->with($notification);
}

$events = Event::updateOrCreate([
'id' => $id,
],
[
'name' => $request->name,
'slug' => $request->slug,
'startAt' => $request->startAt,
'endAt' => $request->endAt
]);

$notification = array(
'message' => 'Event updated.',
'alert-type' => 'success'
);

return redirect()->to('/events')->with($notification);
}



}
Loading