diff --git a/web/app/Helpers/AssetHelper.php b/web/app/Helpers/AssetHelper.php deleted file mode 100644 index faac6b8..0000000 --- a/web/app/Helpers/AssetHelper.php +++ /dev/null @@ -1,121 +0,0 @@ -user; + // TODO: XlXi: creator profile url array_push($data, [ 'Name' => $asset->name, 'Creator' => [ 'Name' => $creator->username, - 'Link' => url('/user/' . strval($creator->username) . '/profile') + 'Url' => 'todo123' ], - 'Thumbnail' => $asset->getThumbnail() + 'Thumbnail' => $asset->getThumbnail(), + 'Url' => route('shop.asset', ['asset' => $asset->id, 'assetName' => Str::slug($asset->name, '-')]) ]); } diff --git a/web/app/Http/Controllers/Web/ShopController.php b/web/app/Http/Controllers/Web/ShopController.php index a1b5656..d9b793a 100644 --- a/web/app/Http/Controllers/Web/ShopController.php +++ b/web/app/Http/Controllers/Web/ShopController.php @@ -2,8 +2,10 @@ namespace App\Http\Controllers\Web; +use App\Models\Asset; use App\Http\Controllers\Controller; use Illuminate\Http\Request; +use Illuminate\Support\Str; class ShopController extends Controller { @@ -11,4 +13,19 @@ class ShopController extends Controller { return view('web.shop.index'); } + + public function showAsset(Request $request, Asset $asset, string $assetName = null) + { + if ($asset->moderated) + abort(404); + + $assetSlug = Str::slug($asset->name, '-'); + if ($assetName != $assetSlug) + return redirect()->route('shop.asset', ['asset' => $asset->id, 'assetName' => $assetSlug]); + + return view('web.shop.asset')->with([ + 'title' => sprintf('%s by %s', $asset->name, $asset->user->username), + 'asset' => $asset + ]); + } } diff --git a/web/app/Models/asset.php b/web/app/Models/asset.php index dc545c5..e7c2242 100644 --- a/web/app/Models/asset.php +++ b/web/app/Models/asset.php @@ -21,11 +21,126 @@ class Asset extends Model 'updated_at' => 'datetime', ]; + protected $assetTypes = [ + /* 0 */ 'Product', + /* 1 */ 'Image', + /* 2 */ 'T-Shirt', + /* 3 */ 'Audio', + /* 4 */ 'Mesh', + /* 5 */ 'Lua', + /* 6 */ 'HTML', + /* 7 */ 'Text', + /* 8 */ 'Hat', + /* 9 */ 'Place', + /* 10 */ 'Model', + /* 11 */ 'Shirt', + /* 12 */ 'Pants', + /* 13 */ 'Decal', + /* 14 */ null, // Doesn't exist on Roblox. + /* 15 */ null, // Doesn't exist on Roblox. + /* 16 */ 'Avatar', + /* 17 */ 'Head', + /* 18 */ 'Face', + /* 19 */ 'Gear', + /* 20 */ null, // Doesn't exist on Roblox. + /* 21 */ 'Badge', + /* 22 */ 'Group Emblem', + /* 23 */ null, // Doesn't exist on Roblox. + /* 24 */ 'Animation', + /* 25 */ 'Arms', + /* 26 */ 'Legs', + /* 27 */ 'Torso', + /* 28 */ 'Right Arm', + /* 29 */ 'Left Arm', + /* 30 */ 'Left Leg', + /* 31 */ 'Right Leg', + /* 32 */ 'Package', + /* 33 */ 'YouTubeVideo', + /* 34 */ 'Game Pass', + /* 35 */ 'App', + /* 36 */ null, // Doesn't exist on Roblox. + /* 37 */ 'Code', + /* 38 */ 'Plugin', + /* 39 */ 'SolidModel', + /* 40 */ 'MeshPart', + /* 41 */ 'Hair Accessory', + /* 42 */ 'Face Accessory', + /* 43 */ 'Neck Accessory', + /* 44 */ 'Shoulder Accessory', + /* 45 */ 'Front Accessory', + /* 46 */ 'Back Accessory', + /* 47 */ 'Waist Accessory', + /* 48 */ 'Climb Animation', + /* 49 */ 'Death Animation', + /* 50 */ 'Fall Animation', + /* 51 */ 'Idle Animation', + /* 52 */ 'Jump Animation', + /* 53 */ 'Run Animation', + /* 54 */ 'Swim Animation', + /* 55 */ 'Walk Animation', + /* 56 */ 'Pose Animation', + /* 57 */ 'Ear Accessory', + /* 58 */ 'Eye Accessory', + /* 59 */ 'LocalizationTableManifest', + /* 60 */ 'LocalizationTableTranslation', + /* 61 */ 'Emote Animation', + /* 62 */ 'Video', + /* 63 */ 'TexturePack', + /* 64 */ 'T-Shirt Accessory', + /* 65 */ 'Shirt Accessory', + /* 66 */ 'Pants Accessory', + /* 67 */ 'Jacket Accessory', + /* 68 */ 'Sweater Accessory', + /* 69 */ 'Shorts Accessory', + /* 70 */ 'Left Shoe Accessory', + /* 71 */ 'Right Shoe Accessory', + /* 72 */ 'Dress Skirt Accessory', + /* 73 */ 'Font Family', + /* 74 */ 'Font Face', + /* 75 */ 'MeshHiddenSurfaceRemoval' + ]; + + protected $assetGenres = [ + /* 0 */ 'All', + /* 1 */ 'Town And City', + /* 2 */ 'Medieval', + /* 3 */ 'Sci-Fi', + /* 4 */ 'Fighting', + /* 5 */ 'Horror', + /* 6 */ 'Naval', + /* 7 */ 'Adventure', + /* 8 */ 'Sports', + /* 9 */ 'Comedy', + /* 10 */ 'Western', + /* 11 */ 'Military', + /* 12 */ 'Skate Park', + /* 13 */ 'Building', + /* 14 */ 'FPS', + /* 15 */ 'RPG' + ]; + + protected $gearAssetGenres = [ + /* 0 */ 'Melee Weapon', + /* 1 */ 'Ranged Weapon', + /* 2 */ 'Explosive', + /* 3 */ 'Power Up', + /* 4 */ 'Navigation Enhancer', + /* 5 */ 'Musical Instrument', + /* 6 */ 'Social Item', + /* 7 */ 'Building Tool', + /* 8 */ 'Personal Transport' + ]; + public function user() { return $this->belongsTo(User::class, 'creatorId'); } + public function typeString() + { + return $this->assetTypes[$this->assetTypeId]; + } + public function latestVersion() { return $this->belongsTo(AssetVersion::class, 'assetVersionId'); diff --git a/web/resources/js/components/Shop.js b/web/resources/js/components/Shop.js index c223f24..2168243 100644 --- a/web/resources/js/components/Shop.js +++ b/web/resources/js/components/Shop.js @@ -307,13 +307,14 @@ class Shop extends Component { :
{ Name }
-Free
+ { /* TODO: XlXi: price */ } +Todo123
By: {{ $asset->user->username }}
+
+
Type: {{ $asset->typeString() }}
+Description:
+