This commit is contained in:
bad 2021-11-14 14:51:49 +01:00
parent 103fe77e74
commit 0e61588895
37 changed files with 778 additions and 61 deletions

2
.gitignore vendored
View file

@ -14,3 +14,5 @@ yarn-error.log
/.idea
/.vscode
.direnv
.php_cs.cache
/storage/mysql

View file

@ -1,5 +1,7 @@
<?php
namespace App\Faker;
use Faker\Provider\Base;
class ProductNameProvider extends Base
@ -80,7 +82,7 @@ class ProductNameProvider extends Base
return static::randomElement(static::$adjectives);
}
public function productName(): string
public function productName(): string
{
$owner = ucfirst(static::randomElement(static::$owners));
$noun = static::randomElement(static::$nouns);
@ -89,4 +91,3 @@ class ProductNameProvider extends Base
return "$owner $adj $noun";
}
}
?>

View file

@ -9,5 +9,7 @@ use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
use AuthorizesRequests;
use DispatchesJobs;
use ValidatesRequests;
}

View file

@ -0,0 +1,54 @@
<?php
namespace App\Http\Controllers;
use App\Models\Image;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
class ImageController extends Controller
{
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view("uploadImage");
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$validatedData = $request->validate([
// The server should make sure to serve SVG files with the correct CSP to prevent XSS
'image' => 'required|image|mimes:jpg,png,jpeg,gif,svg,webp|max:5000',
]);
/*
Once the image is validated , create the name on the image
*/
$image = new Image();
$image->uuid = Str::uuid();
$image->path = $request->file('image')->store("uploads");
$image->save();
}
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Image $image
* @return \Illuminate\Http\Response
*/
public function destroy(Image $image)
{
$image->delete();
}
}

View file

@ -9,12 +9,13 @@ use Illuminate\Support\Facades\Hash;
class LoginController extends Controller
{
public function authenticate(Request $request) {
public function authenticate(Request $request)
{
$creds = $request->validate([
'email' => ['required', 'email'],
'password' => ['required']
]);
if(Auth::attempt($creds)) {
if (Auth::attempt($creds)) {
$request->session()->regenerate();
return redirect()->intended();
}
@ -23,7 +24,8 @@ class LoginController extends Controller
]);
}
public function register(Request $request) {
public function register(Request $request)
{
Auth::logout();
$creds = $request->validate([
@ -37,7 +39,8 @@ class LoginController extends Controller
return redirect("login")->withSuccess("Success! Now login");
}
public function logout(Request $request) {
public function logout(Request $request)
{
Auth::logout();
$request->session()->invalidate();
$request->session()->regenerate();
@ -45,7 +48,8 @@ class LoginController extends Controller
return back();
}
public function view() {
public function view()
{
return view("login", []);
}
}

View file

@ -0,0 +1,114 @@
<?php
namespace App\Http\Controllers;
use App\Models\Addres;
use App\Models\Order;
use App\Models\Product;
use Error;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
class OrderController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view("order/create");
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$user = Auth::user();
if (!$user) {
throw new AccessDeniedHttpException("Not logged in");
}
$validated = $request->validate([
'products' => 'required|array',
'products.*' => 'exists:products,uuid'
]);
DB::transaction(function () use ($validated, $user) {
$products = array_map(fn ($v) => Product::query()->where("uuid", $v)->first(), $validated["products"]);
$order = new Order($products);
$order->user()->associate($user);
$order->cost = array_reduce($products,fn ($c, $i) => $c+=$i->price,0);
return $order->save();
});
}
/**
* Display the specified resource.
*
* @return \Illuminate\Http\Response
*/
public function show(Order $order)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @return \Illuminate\Http\Response
*/
public function edit(Order $order)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Order $order)
{
$validated = $request->validate([
'address' => 'string',
]);
if(isset($validated["address"])) {
$address = $order->address()->withDefault(fn() => new Addres($validated));
$address->address = $validated["address"];
$order->save();
}
}
/**
* Remove the specified resource from storage.
*
* @return \Illuminate\Http\Response
*/
public function destroy(Order $order)
{
throw new Error("TODO");
//
}
}

View file

@ -8,7 +8,6 @@ use Illuminate\Support\Facades\Log;
class ProductController extends Controller
{
public function index()
{
// TMP do something better at some point maybe idk
@ -91,7 +90,6 @@ class ProductController extends Controller
*/
public function destroy(Product $product)
{
echo $product;
$product->delete();
return redirect()->route("product.index");
}

View file

@ -0,0 +1,19 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class order extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
return parent::toArray($request);
}
}

15
app/Models/Addres.php Normal file
View file

@ -0,0 +1,15 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Addres extends Model
{
use HasFactory;
protected $fillable = [
'address',
];
}

View file

@ -4,43 +4,42 @@ namespace App\Models;
use Illuminate\Support\Str;
/*
/*
* A trait for all models that use a UUID as a primary key
*
*
* This helps us avoid enumeration attacks
*
*
*/
trait HasUUID
{
{
protected static function getPrimaryKey()
{
return self::uuidField();
}
protected static function getPrimaryKey()
{
return self::uuidField();
}
/**
* Defines the UUID field for the model.
* @return string
*/
protected static function uuidField()
{
return 'uuid';
}
/**
* Defines the UUID field for the model.
* @return string
*/
protected static function uuidField()
{
return 'uuid';
}
public function getIncrementing()
{
return false;
}
public function getIncrementing()
{
return false;
}
/**
* Generate UUID v4 when creating model.
*/
protected static function boot()
{
parent::boot();
/**
* Generate UUID v4 when creating model.
*/
protected static function boot()
{
parent::boot();
static::creating(function ($model) {
$model->{self::uuidField()} = (string) Str::uuid();
});
}
}
static::creating(function ($model) {
$model->{self::uuidField()} = (string) Str::uuid();
});
}
}

21
app/Models/Image.php Normal file
View file

@ -0,0 +1,21 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;
class Image extends Model
{
use HasFactory;
use HasUUID;
public $primaryKey = "uuid";
protected $fillable = [];
public function URL()
{
Storage::url($this->path);
}
}

28
app/Models/Order.php Normal file
View file

@ -0,0 +1,28 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Order extends Model
{
use HasFactory;
use HasUUID;
public $primaryKey = "uuid";
protected $fillable = ['products'];
public function address()
{
return $this->belongsTo(Addres::class, "id", "addressId");
}
public function user()
{
return $this->belongsTo(User::class, "userId", "uuid");
}
public function products()
{
return $this->belongsToMany("App\Product", "orderProduct","productId", "orderId");
}
}

View file

@ -7,10 +7,11 @@ use Illuminate\Database\Eloquent\Model;
class Product extends Model
{
use HasFactory, HasUUID;
use HasFactory;
use HasUUID;
public $primaryKey = "uuid";
protected $fillable = [
'name',
'description',

View file

@ -7,8 +7,12 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
class User extends Authenticatable {
use HasApiTokens, HasFactory, HasUUID, Notifiable;
class User extends Authenticatable
{
use HasApiTokens;
use HasFactory;
use HasUUID;
use Notifiable;
public $primaryKey = "uuid";
/**

View file

@ -5,7 +5,8 @@ namespace App\Providers;
use App\Faker\ProductNameProvider;
use Illuminate\Support\ServiceProvider;
use Faker\{Factory, Generator};
use Faker\Factory;
use Faker\Generator;
class FakerServiceProvider extends ServiceProvider
{

View file

@ -10,7 +10,9 @@
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.54",
"laravel/sanctum": "^2.11",
"laravel/tinker": "^2.5"
"laravel/tinker": "^2.5",
"php-decimal/laravel": "^1.1",
"php-decimal/php-decimal": "^1.1"
},
"require-dev": {
"facade/ignition": "^2.5",

179
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "6cadd819a6415b190ae2704ced6e6c8b",
"content-hash": "844437f75eed2577e6c25d111a4ecd28",
"packages": [
{
"name": "asm89/stack-cors",
@ -1978,6 +1978,183 @@
},
"time": "2021-04-09T13:42:10+00:00"
},
{
"name": "php-decimal/globals",
"version": "v1.1.0",
"source": {
"type": "git",
"url": "https://github.com/php-decimal/globals.git",
"reference": "589a296b471a3913ed41396d6fcae2a321788a78"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-decimal/globals/zipball/589a296b471a3913ed41396d6fcae2a321788a78",
"reference": "589a296b471a3913ed41396d6fcae2a321788a78",
"shasum": ""
},
"require": {
"php": ">=7.0.0",
"php-decimal/php-decimal": "^1.1.0"
},
"type": "library",
"autoload": {
"files": [
"globals.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Rudi Theunissen",
"email": "rtheunissen@php.net"
}
],
"description": "Globals helpers for the decimal extension",
"support": {
"issues": "https://github.com/php-decimal/globals/issues",
"source": "https://github.com/php-decimal/globals/tree/v1.1.0"
},
"time": "2018-11-20T21:18:50+00:00"
},
{
"name": "php-decimal/laravel",
"version": "v1.1.2",
"source": {
"type": "git",
"url": "https://github.com/php-decimal/laravel.git",
"reference": "fbc4137d40d1dfde1457ecc113dede57ac0de841"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-decimal/laravel/zipball/fbc4137d40d1dfde1457ecc113dede57ac0de841",
"reference": "fbc4137d40d1dfde1457ecc113dede57ac0de841",
"shasum": ""
},
"require": {
"php": ">=7.0.0",
"php-decimal/globals": "^1.1.0",
"php-decimal/php-decimal": "^1.1.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Decimal\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Rudi Theunissen",
"email": "rtheunissen@php.net"
}
],
"description": "Laravel integration package for decimal support",
"support": {
"issues": "https://github.com/php-decimal/laravel/issues",
"source": "https://github.com/php-decimal/laravel/tree/v1.0.2"
},
"time": "2019-07-05T23:45:07+00:00"
},
{
"name": "php-decimal/php-decimal",
"version": "v1.1.0",
"source": {
"type": "git",
"url": "https://github.com/php-decimal/php-decimal.git",
"reference": "ee8d92648fd06e82f9bfe0406d3670ebcddd946a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-decimal/php-decimal/zipball/ee8d92648fd06e82f9bfe0406d3670ebcddd946a",
"reference": "ee8d92648fd06e82f9bfe0406d3670ebcddd946a",
"shasum": ""
},
"require": {
"ext-decimal": "^1.1",
"php": ">=7.0.0",
"php-decimal/stubs": "^1.1"
},
"type": "library",
"autoload": {
"psr-4": {
"Decimal\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Rudi Theunissen",
"email": "rtheunissen@php.net"
}
],
"description": "Correctly-rounded arbitrary precision decimal floating point",
"keywords": [
"decimal",
"math",
"number",
"precision"
],
"support": {
"issues": "https://github.com/php-decimal/php-decimal/issues",
"source": "https://github.com/php-decimal/php-decimal/tree/v1.1.0"
},
"time": "2018-11-20T20:49:48+00:00"
},
{
"name": "php-decimal/stubs",
"version": "v1.1.0",
"source": {
"type": "git",
"url": "https://github.com/php-decimal/stubs.git",
"reference": "168bb0d58bb398d7da739da0da99df2a9e1fc773"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-decimal/stubs/zipball/168bb0d58bb398d7da739da0da99df2a9e1fc773",
"reference": "168bb0d58bb398d7da739da0da99df2a9e1fc773",
"shasum": ""
},
"require": {
"php": ">=7.0.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Decimal\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Rudi Theunissen",
"email": "rtheunissen@php.net"
}
],
"description": "IDE and static analysis helper for the decimal extension",
"keywords": [
"decimal",
"math",
"number",
"precision"
],
"support": {
"issues": "https://github.com/php-decimal/stubs/issues",
"source": "https://github.com/php-decimal/stubs/tree/v1.1.0"
},
"time": "2018-11-20T20:48:40+00:00"
},
{
"name": "phpoption/phpoption",
"version": "1.8.0",

View file

@ -67,7 +67,7 @@ return [
*/
'links' => [
public_path('storage') => storage_path('app/public'),
public_path('storage') => storage_path('app'),
],
];

View file

@ -0,0 +1,28 @@
<?php
namespace Database\Factories;
use App\Models\Order;
use Illuminate\Database\Eloquent\Factories\Factory;
class OrderFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Order::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
return [
//
];
}
}

View file

@ -25,6 +25,7 @@ class ProductFactory extends Factory
return [
'uuid' => $this->faker->unique()->uuid(),
'name' => $this->faker->productName(),
'price' => $this->faker->numberBetween(1,32124),
'description' => $this->faker->text(10000),
];
}

View file

@ -17,6 +17,7 @@ class CreateProductsTable extends Migration
$table->uuid("uuid")->primary()->unique();
$table->string("name", 255);
$table->string("description", 10000);
$table->decimal("price");
$table->timestamps();
});
}

View file

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateImagesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('images', function (Blueprint $table) {
$table->uuid("uuid")->unique()->primary;
$table->string('path')->unique();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('images');
}
}

View file

@ -0,0 +1,55 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateOrdersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('addresses', function (Blueprint $table) {
$table->id('id');
$table->foreignUuid("userId")->references("uuid")->on("users");
// Address validation for international users is basically impossible so just use a string
$table->string("addres");
$table->timestamps();
});
Schema::create('orders', function (Blueprint $table) {
$table->uuid("uuid")->unique()->primary();
$table->boolean("fulfilled")->default(false);
$table->foreignUuid("userId")->references("uuid")->on("users");
$table->foreignId("addressId")->nullable()->references("id")->on("addresses");
$table->decimal("cost");
$table->boolean("paid")->default(false);
$table->timestamps();
});
Schema::create("orderProduct", function (Blueprint $table) {
$table->foreignUuid("productId")->references("uuid")->on("products")->cascadeOnUpdate()->cascadeOnDelete();
$table->foreignUuid("orderId")->references("uuid")->on("orders")->cascadeOnUpdate()->cascadeOnDelete();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('orderProduct');
Schema::dropIfExists('orders');
Schema::dropIfExists('addresses');
}
}

View file

@ -0,0 +1,18 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class OrderSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
}
}

View file

@ -3,7 +3,7 @@ version: '3'
services:
laravel.test:
build:
context: ./vendor/laravel/sail/runtimes/8.0
context: ./docker/8.0
dockerfile: Dockerfile
args:
WWWGROUP: '${WWWGROUP}'
@ -24,7 +24,7 @@ services:
depends_on:
- mysql
mysql:
image: 'mysql:8.0'
image: 'mariadb:10'
ports:
- '${FORWARD_DB_PORT:-3306}:3306'
environment:

57
docker/8.0/Dockerfile Normal file
View file

@ -0,0 +1,57 @@
FROM ubuntu:21.04
LABEL maintainer="Taylor Otwell"
ARG WWWGROUP
WORKDIR /var/www/html
ENV DEBIAN_FRONTEND noninteractive
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update \
&& apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 \
&& mkdir -p ~/.gnupg \
&& chmod 600 ~/.gnupg \
&& echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf \
&& apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E5267A6C \
&& apt-key adv --homedir ~/.gnupg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C300EE8C \
&& echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu hirsute main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \
&& apt-get update \
&& apt-get install -y php8.0-cli php8.0-dev \
php8.0-pgsql php8.0-sqlite3 php8.0-gd \
php8.0-curl php8.0-memcached \
php8.0-imap php8.0-mysql php8.0-mbstring \
php8.0-xml php8.0-zip php8.0-bcmath php8.0-soap \
php8.0-intl php8.0-readline php8.0-pcov \
php8.0-msgpack php8.0-igbinary php8.0-ldap \
php8.0-redis php8.0-swoole php8.0-xdebug \
php-decimal \
&& php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \
&& curl -sL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get install -y nodejs \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
&& apt-get update \
&& apt-get install -y yarn \
&& apt-get install -y mysql-client \
&& apt-get install -y postgresql-client \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.0
RUN groupadd --force -g $WWWGROUP sail
RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail
COPY start-container /usr/local/bin/start-container
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY php.ini /etc/php/8.0/cli/conf.d/99-sail.ini
RUN chmod +x /usr/local/bin/start-container
EXPOSE 8000
ENTRYPOINT ["start-container"]

4
docker/8.0/php.ini Normal file
View file

@ -0,0 +1,4 @@
[PHP]
post_max_size = 100M
upload_max_filesize = 100M
variables_order = EGPCS

View file

@ -0,0 +1,17 @@
#!/usr/bin/env bash
if [ ! -z "$WWWUSER" ]; then
usermod -u $WWWUSER sail
fi
if [ ! -d /.composer ]; then
mkdir /.composer
fi
chmod -R ugo+rw /.composer
if [ $# -gt 0 ];then
exec gosu $WWWUSER "$@"
else
/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
fi

View file

@ -0,0 +1,14 @@
[supervisord]
nodaemon=true
user=root
logfile=/var/log/supervisor/supervisord.log
pidfile=/var/run/supervisord.pid
[program:php]
command=/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan serve --host=0.0.0.0 --port=80
user=sail
environment=LARAVEL_SAIL="1"
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

View file

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
</style>
</head>
<body>
@if(Session::has('success'))
<div class="alert alert-success">
{{Session::get('success')}}
</div>
@endif
<div>
<form method="post" action="./">
<input type="text" name="products[0]">
<input type="submit">
@csrf
</form>
</div>
</body>
</html>

View file

@ -12,9 +12,9 @@
<p>
{{ $product }}
</p>
<form method="POST">
<button type="submit">Delete</button>
@method('DELETE')
<form method="POST">
<button type="submit">Delete</button>
@method('DELETE')
@csrf
</form>
</div>

View file

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
</style>
</head>
<body>
@if(Session::has('success'))
<div class="alert alert-success">
{{Session::get('success')}}
</div>
@endif
<div>
<form method="post" action="{{ route("image.store") }}" enctype="multipart/form-data">
<input type="file" name="image">
<input type="submit">
@csrf
</form>
</div>
</body>
</html>

View file

@ -18,4 +18,3 @@ use Illuminate\Support\Facades\Artisan;
Artisan::command('inspire', function () {
$this->comment(Inspiring::quote());
})->purpose('Display an inspiring quote');

View file

@ -1,6 +1,8 @@
<?php
use App\Http\Controllers\ImageController;
use App\Http\Controllers\LoginController;
use App\Http\Controllers\OrderController;
use App\Http\Controllers\ProductController;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
@ -21,7 +23,7 @@ Route::get('/', function () {
});
Route::get('/user', function () {
$user = Auth::user();
$user = Auth::user();
return view("user", ["user"=>$user]);
})->middleware("auth");
@ -32,3 +34,5 @@ Route::post('/register', [LoginController::class, "register"])->name("register")
Route::any("/logout", [LoginController::class, "logout"])->name("logout");
Route::resource("product", ProductController::class);
Route::resource("order", OrderController::class);
Route::resource("image", ImageController::class)->only(["store", "delete", "create"]);

View file

@ -1,5 +1,5 @@
{ pkgs ? import <nixpkgs> { } }:
pkgs.mkShell {
# nativeBuildInputs is usually what you want -- tools you need to run
nativeBuildInputs = with pkgs; [ php80Packages.composer php80 yarn docker-compose docker];
nativeBuildInputs = with pkgs; [ php80Packages.php-cs-fixer php80Packages.composer php80 yarn docker-compose docker];
}

View file

@ -1,2 +0,0 @@
*
!.gitignore

View file

@ -15,6 +15,5 @@ class RegistrationTest extends TestCase
{
$this->post("/register", ["email" => "a@a.com", "username" => "aaa", "password" => "password"])->assertRedirect();
$this->post("/login", ["email" => "a@a.com", "username" => "aaa", "password" => "password"])->assertRedirect("/");
}
}