Skip to content

Commit

Permalink
add map pool creation
Browse files Browse the repository at this point in the history
  • Loading branch information
stanrunge committed Nov 10, 2024
1 parent 8b68468 commit 7abc09e
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 25 deletions.
1 change: 1 addition & 0 deletions packages/frontend/web-laravel/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ yarn-error.log
/.idea
/.vscode
/.zed
.php-cs-fixer.cache
1 change: 0 additions & 1 deletion packages/frontend/web-laravel/.php-cs-fixer.cache

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ public function index()
*/
public function create()
{
//
return Inertia::render('MapPools/Create');
}

/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//
MapPool::create($request->all());

return redirect('/map_pools');
}

/**
Expand Down
2 changes: 2 additions & 0 deletions packages/frontend/web-laravel/app/Models/MapPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class MapPool extends Model
{
use HasFactory;

protected $fillable = ['name'];

public function mapPoolMaps(): HasMany
{
return $this->hasMany(MapPoolMap::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class() extends Migration {
return new class () extends Migration {
/**
* Run the migrations.
*/
Expand All @@ -24,6 +24,7 @@ public function up(): void

Schema::create('map_pools', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->timestamps();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<script>
import Layout from '@/Shared/Layout.svelte'
import { useForm } from '@inertiajs/svelte'
let form = useForm({
name: '',
})
const createMapPool = () => {
$form.post('/map_pools')
}
</script>

<Layout>
<form on:submit|preventDefault={createMapPool}>
<label for="title">Title</label>
<input type="text" id="title" bind:value={$form.name} />

<button type="submit">Create Map Pool</button>
</form>
</Layout>
Original file line number Diff line number Diff line change
@@ -1,32 +1,14 @@
<script>
import { preventDefault } from 'svelte/legacy'
import { useForm, router } from '@inertiajs/svelte'
import { router, Link } from '@inertiajs/svelte'
import Layout from '../../Shared/Layout.svelte'
let { mapPools } = $props()
let values = {
mods: [
{
id: 1,
},
],
}
let form = useForm(values)
function storeMapPool() {
$form.post('/map_pools')
}
</script>

<Layout>
<form onsubmit={preventDefault(storeMapPool)}>
<input type="text" />

<Link href="/map_pools/create">
<button>Create</button>
</form>
</Link>

<table class="table-auto">
<thead>
Expand Down

0 comments on commit 7abc09e

Please sign in to comment.