public function buyProduct($id){
$product = Product::where('id',$id)->get();
$userId = Auth::user()->id;
$sellerUserId = $product->first()->seller_user_id;
$sellerUserIdBalance = User::where('id',$sellerUserId)->get()->first()->balance;
User::where('id', $sellerUserId)->update(array('balance' => $sellerUserIdBalance+$productPrice));
old()
old('hobby')
у вас будет массив@foreach(old('hobby') as $value)
<input name="hobby[]" value="{{ $value }}"
@endforech
@if ($errors->any())
@foreach ($errors->all() as $error)
<p>{{ $error }}</p>
@endforeach
@endif
composer create-project laravel/laravel example-app
И все бы хорошо, но я не нашел об этом информации в документации.
Route::post('/contacts', [ContactsController::class, 'receive'])
->middleware([\Spatie\Honeypot\ProtectAgainstSpam::class])
->name('site.form.feedback');
<form class="form" method="post" action="{{ route('site.form.feedback') }}">
@csrf
@honeypot
<VirtualHost *:8080>
DocumentRoot "d:/dev/projects/wofh-tools/wofh-tools.project/public"
ServerName "wofh-tools.project"
ServerAlias "wofh-tools.project"
SetEnvIfNoCase X-Forwarded-Proto https HTTPS=on
</VirtualHost>
server {
listen 127.0.0.1:80;
listen 127.0.0.1:443 ssl;
server_name wofh-tools.project ;
ssl_certificate "d:/openserver/userdata/config/cert_files/server.crt";
ssl_certificate_key "d:/openserver/userdata/config/cert_files/server.key";
location ~ /\. {deny all;}
location / {
proxy_buffer_size 64k;
proxy_buffering on;
proxy_buffers 4 64k;
proxy_connect_timeout 5s;
proxy_ignore_client_abort off;
proxy_intercept_errors off;
proxy_pass http://127.0.0.1:3333;
proxy_pass_header Server;
proxy_read_timeout 5m;
proxy_redirect off;
proxy_send_timeout 5m;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /api {
proxy_pass http://wofh-tools.project:8080/api;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /admin {
proxy_pass http://wofh-tools.project:8080/admin;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location /tracy {
proxy_pass http://wofh-tools.project:8080/tracy;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location /vendor {
proxy_pass http://wofh-tools.project:8080/vendor;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location /storage {
proxy_pass http://wofh-tools.project:8080/storage;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
artisan make:model Article -m
Model created successfully.
Created Migration: 2021_05_28_111836_create_articles_table
class CreateArticlesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('articles', function (Blueprint $table) {
$table->id();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('articles');
}
}
public function store(Request $request) {
$validator = Validator::make($request->all(), [
'title' => 'required|string',
'source' => 'required|string',
'category_id' => 'required|integer|exists:categories,id',
]);
try {
$input = $validator->validate();
} catch (ValidationException $e) {
return redirect()->back()->withErrors($validator)->withInput();
}
$input['id'] = Auth::user()->id;
$input['private'] = $request->has('private') ? 0 : 1;
Pass::create($input);
return redirect()->route('home');
}