Initial commit

This commit is contained in:
2025-03-16 01:51:35 +03:00
commit d3a0958e46
65 changed files with 12929 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
<?php
namespace App\Http\Controllers;
use App\Models\Ingredient;
use App\Models\Remainder;
use Database\Seeders\IngredientsSeeder;
use Illuminate\Http\Request;
use Illuminate\View\View;
class Calculator extends Controller
{
/**
* Показать профиль конкретного пользователя.
*/
public function index(): View
{
$allWeights = 0;
$allRemainder = 0;
$elements = Ingredient::all();
foreach ($elements as &$element) {
$allWeights += $element['batch_weight'];
$remainderModel = Remainder::where('ingredient_id', $element['id'])->first();
$element['remainder'] = $remainderModel ? $remainderModel['remainder'] : 0;
$allRemainder += $element['remainder'];
}
return view(
'calculator',
[
'elements' => $elements,
'allWeights' => $allWeights,
'allRemainder' => $allRemainder,
]
);
}
}

View File

@@ -0,0 +1,8 @@
<?php
namespace App\Http\Controllers;
abstract class Controller
{
//
}

10
app/Models/Ingredient.php Normal file
View File

@@ -0,0 +1,10 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Ingredient extends Model
{
//
}

10
app/Models/Remainder.php Normal file
View File

@@ -0,0 +1,10 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Remainder extends Model
{
//
}

48
app/Models/User.php Normal file
View File

@@ -0,0 +1,48 @@
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var list<string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
//
}
}