-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
190 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class LocationItem extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $fillable = ['location_id', 'sort', 'page_id']; | ||
|
||
protected $appends = ['type']; | ||
|
||
public function getTypeAttribute() | ||
{ | ||
return "locationItem"; | ||
} | ||
|
||
public function page() | ||
{ | ||
return $this->belongsTo(Page::class); | ||
} | ||
|
||
public function location() | ||
{ | ||
return $this->belongsTo(Location::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
api/database/migrations/2024_02_18_185901_create_location_items_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::create('location_items', function (Blueprint $table) { | ||
$table->id(); | ||
$table->foreignId('location_id')->nullable()->constrained()->onDelete('cascade'); | ||
$table->integer('sort')->nullable(); | ||
$table->unsignedBigInteger('page_id'); | ||
$table->foreign('page_id')->references('id')->on('pages')->onDelete('cascade'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('location_items'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<template> | ||
<DragItemBox | ||
:boxTitle="boxTitle" | ||
:item="item" | ||
@delete="(event) => $emit('delete', event)" | ||
@startedDragging="$emit('startedDragging')" | ||
@endedDragging="$emit('endedDragging')" | ||
> | ||
<Card class="space-y-2"> | ||
<SelectComponent | ||
selection="LocationItem" | ||
@selectLocationItem="handleChange" | ||
:value="item.locationId" | ||
:options="options" | ||
/> | ||
</Card> | ||
</DragItemBox> | ||
</template> | ||
|
||
<script> | ||
import Card from "../Card.vue"; | ||
import SelectComponent from "../SelectComponent.vue"; | ||
import DragItemBox from "../DragItemBox.vue"; | ||
export default { | ||
components: { Card, SelectComponent, DragItemBox }, | ||
props: ["item", "boxTitle"], | ||
emits: [ | ||
"updatePage", | ||
"changeLocation", | ||
"delete", | ||
"startedDragging", | ||
"endedDragging", | ||
], | ||
data() { | ||
return { | ||
options: [], | ||
}; | ||
}, | ||
methods: { | ||
async getLocations() { | ||
try { | ||
const response = await this.callApi("get", "locations"); | ||
this.options = response.data.data; | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
}, | ||
handleChange(value) { | ||
this.$emit("changeLocation", { locationId: value, id: this.item.id }); | ||
}, | ||
}, | ||
computed: {}, | ||
async created() { | ||
await this.getLocations(); | ||
}, | ||
}; | ||
</script> | ||
|
||
<style></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<template> | ||
<div> | ||
<MapComponent class="w-full h-96" :markers="[item.location]" /> | ||
</div> | ||
</template> | ||
<script> | ||
import MapComponent from "./MapComponent.vue"; | ||
export default { | ||
props: ["item"], | ||
data() { | ||
return {}; | ||
}, | ||
methods: {}, | ||
async created() {}, | ||
components: { MapComponent }, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters