Browse Source

adding

master
Björn 3 years ago
parent
commit
d577c03105
10 changed files with 136 additions and 21 deletions
  1. +20
    -4
      app/Http/Controllers/BucketController.php
  2. +19
    -0
      app/Models/Bucket.php
  3. +3
    -3
      database/migrations/2020_11_20_113852_create_buckets_table.php
  4. +2
    -2
      public/css/bootstrap.css
  5. +1
    -1
      public/js/bucket.js
  6. +1
    -1
      public/js/home.js
  7. +55
    -7
      resources/js/components/bucket/form.riot
  8. +8
    -0
      resources/scss/bootstrap.scss
  9. +21
    -0
      resources/views/bucket/single.blade.php
  10. +6
    -3
      routes/web.php

+ 20
- 4
app/Http/Controllers/BucketController.php View File

@ -11,12 +11,19 @@ class BucketController extends BaseController
{ {
use AuthorizesRequests, DispatchesJobs, ValidatesRequests; use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
public function get()
/**
*
*
* @return
*
*/
public function single()
{ {
return view('bucket.single');
} }
/** /**
*
* *
* @return [type] [description] * @return [type] [description]
* *
@ -26,16 +33,25 @@ class BucketController extends BaseController
return view('bucket.create'); return view('bucket.create');
} }
/**
*
*
*/
public function store() public function store()
{ {
$validated = request()->validate([ $validated = request()->validate([
'title' => 'required|max:255',
'name' => 'required|max:255',
'description' => 'max:255',
'path' => 'present',
'is_public' => 'boolean', 'is_public' => 'boolean',
]); ]);
if ($validated) { if ($validated) {
$bucket = Bucket::create($validated);
return redirect() return redirect()
->route('bucket.get', ['uuid' => 12]);
->route('bucket.single', ['uuid' => 12]);
} else { } else {
return back() return back()
->withInput(); ->withInput();


+ 19
- 0
app/Models/Bucket.php View File

@ -0,0 +1,19 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Bucket extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name',
'description',
'path',
];
}

database/migrations/2020_11_20_113852_create_hubs_table.php → database/migrations/2020_11_20_113852_create_buckets_table.php View File

@ -4,7 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
class CreateHubsTable extends Migration
class CreateBucketsTable extends Migration
{ {
/** /**
* Run the migrations. * Run the migrations.
@ -13,7 +13,7 @@ class CreateHubsTable extends Migration
*/ */
public function up() public function up()
{ {
Schema::create('hubs', function (Blueprint $table) {
Schema::create('buckets', function (Blueprint $table) {
$table->uuid('id')->primary(); $table->uuid('id')->primary();
$table->string('name'); $table->string('name');
@ -31,6 +31,6 @@ class CreateHubsTable extends Migration
*/ */
public function down() public function down()
{ {
Schema::dropIfExists('hubs');
Schema::dropIfExists('buckets');
} }
} }

+ 2
- 2
public/css/bootstrap.css
File diff suppressed because it is too large
View File


+ 1
- 1
public/js/bucket.js
File diff suppressed because it is too large
View File


+ 1
- 1
public/js/home.js
File diff suppressed because it is too large
View File


+ 55
- 7
resources/js/components/bucket/form.riot View File

@ -4,18 +4,55 @@
<input type="hidden" name="_token" value={ state.csrfToken } if={ state.csrfToken } /> <input type="hidden" name="_token" value={ state.csrfToken } if={ state.csrfToken } />
<!-- title -->
<!-- name -->
<div class="field is-horizontal"> <div class="field is-horizontal">
<div class="field-label is-normal"> <div class="field-label is-normal">
<label class="label" for="title">
title
<label class="label required" for="name">
name
</label> </label>
</div> </div>
<div class="field-body"> <div class="field-body">
<div class="field"> <div class="field">
<p class="control"> <p class="control">
<input id="title" class={ getClasses('title', 'input') } type="text" name="title" value={ props.title } onkeyup={ (event) => { state.validator.handle(event, 'title') }} />
<field-error errors={ state.validator.errors('title') } ></field-error>
<input id="name" class={ getClasses('name', 'input') } type="text" name="name" value={ props.name } onkeyup={ (event) => { state.validator.handle(event, 'name') }} />
<field-error errors={ state.validator.errors('name') } ></field-error>
</p>
</div>
</div>
</div>
<!-- description -->
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label" for="description">
description
</label>
</div>
<div class="field-body">
<div class="field">
<p class="control">
<textarea id="description" class={ getClasses('description', 'textarea') } name="description" value={ props.description } onkeyup={ (event) => { state.validator.handle(event, 'description') }}></textarea>
<field-error errors={ state.validator.errors('description') } ></field-error>
</p>
</div>
</div>
</div>
<!-- path -->
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label" for="name">
path
</label>
</div>
<div class="field-body">
<div class="field">
<p class="control">
<input id="path" class={ getClasses('path', 'input') } type="text" name="path" value={ props.path } onkeyup={ (event) => { state.validator.handle(event, 'path') }} />
<field-error errors={ state.validator.errors('path') } ></field-error>
<span class="help">
path for storage files, if empty default path will be used
</span>
</p> </p>
</div> </div>
</div> </div>
@ -31,6 +68,9 @@
<div class="field-body"> <div class="field-body">
<div class="field"> <div class="field">
<input id="public" type="checkbox" name="public" value="1" checked={ props.public }> <input id="public" type="checkbox" name="public" value="1" checked={ props.public }>
<span class="help">
everyone can see bucket, files and download them
</span>
</div> </div>
</div> </div>
</div> </div>
@ -69,8 +109,16 @@
*/ */
onBeforeMount(props, state) { onBeforeMount(props, state) {
state.validator = new Validator({ state.validator = new Validator({
title: {
presence: true
name: {
presence: true,
length: {
maximum: 255
}
},
description: {
length: {
maximum: 255
}
} }
}, this) }, this)


+ 8
- 0
resources/scss/bootstrap.scss View File

@ -60,5 +60,13 @@ input[type=checkbox] {
top: 0.7em; top: 0.7em;
} }
label.required {
&:after {
content: "\2731";
vertical-align: top;
font-size: 80%;
}
}
@include component__accordion(); @include component__accordion();
@include component__buckets(); @include component__buckets();

+ 21
- 0
resources/views/bucket/single.blade.php View File

@ -0,0 +1,21 @@
@extends('layout')
@section('head')
<meta name="csrf-token" content="{{ csrf_token() }}">
@endsection
@section('main')
<div class="container is-fluid">
<h1 class="title is-3 is-spaced">
Create Bucket
</h1>
<urban-bucket-form></urban-bucket-form>
</div>
@push('scripts')
<script type="text/javascript" src="/js/bucket.js"></script>
<script type="text/javascript" defer>
riot.mount('urban-bucket-form', {!! json_encode(old()) !!});
</script>
@endpush
@endsection

+ 6
- 3
routes/web.php View File

@ -13,13 +13,16 @@ use Illuminate\Support\Facades\Route;
| |
*/ */
// pattern
Route::pattern('uuid', '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}');
// routes
Route::get('/', 'App\Http\Controllers\HomeController@show'); Route::get('/', 'App\Http\Controllers\HomeController@show');
Route::prefix('bucket')->group(function() { Route::prefix('bucket')->group(function() {
Route::get('create', 'App\Http\Controllers\BucketController@create');
Route::get('create', 'App\Http\Controllers\BucketController@create')->name('bucket.create');
Route::post('create', 'App\Http\Controllers\BucketController@store'); Route::post('create', 'App\Http\Controllers\BucketController@store');
Route::get('{uuid}', 'App\Http\Controllers\BucketController@get')->name('bucket.get');
Route::get('{uuid}', 'App\Http\Controllers\BucketController@single')->name('bucket.single');
}); });
/*** /***


Loading…
Cancel
Save