mteb/FreshStackRetrieval huggingface dataset:
hello I'm new for livewire 3 I have table inside form, data table having  radio button for yes or no
after selecting yes or no I'm going to submit that form that time I want to store fetch detail like id and name along this. now I'm any getting radio button value, me to solve
form page

my code form
<div class="modal-body">
    <form wire:submit.prevent="Save" autocomplete="off">
      <div class="card card-bordered card-preview table-responsive ">
        <div class="card-inner "> 
          <table class="datatable  table   ">
            <thead>
              <tr>
                <th style=" border: 1px solid black; text-align: center;">SL</th>
                <th style=" border: 1px solid black; text-align: center;">ID No</th> 
                <th style=" border: 1px solid black; text-align: center;">NAME</th>
                <th style=" border: 1px solid black; text-align: center;">YES</th>
                <th style=" border: 1px solid black; text-align: center;">NO</th>
              </tr>
            </thead>
            <tbody> 
 @foreach ($UserDetail as $key=>$UserDetails) 
 @php $ID = 0+$key @endphp
<td style=" border: 1px solid black; text-align: center;">
                {{ $key + 1  }}
              </td> 
              <td style=" border: 1px solid black; text-align: center;">
                {{ $UserDetails->id }}
              </td>
              <td style=" border: 1px solid black; text-align: center;">
                {{ $UserDetails->name }}
              </td>
              <td style=" border: 1px solid black; text-align: center;">
                <div class="custom-control custom-control-md custom-radio ">
                  <input type="radio" wire:model="TableInput.{{$ID}}.data" class="custom-control-input" name="TableInputs[{{$ID}}]" id="sv2-preference-fedev{{$ID}}" value="YES" required>
                  <label class="custom-control-label" for="sv2-preference-fedev{{$ID}}"></label>
                </div>
              </td>
              <td style=" border: 1px solid black; text-align: center;">
                <div style="text-align: center;" class="custom-control custom-control-md custom radio"><input type="radio" wire:model="TableInput.{{$ID}}.data" class="custom-control-input" name="TableInputs[{{$ID}}]" id="sv2-preference-uxdis{{$ID}}" value="NO" required>
                  <label class="custom-control-label" for="sv2-preference-uxdis{{$ID}}"></label>
                </div>
              </td> 
              </tr> 
      @endforeach 
            </tbody>
          </table>
        </div>
      </div>
      <br>
      <div  >
        <button type="submit" class="btn btn-md btn-primary">SAVE  </button>
      </div>
    </form>
  </div>

Controller
class StudentAttendance extends Component
{
public $name; 
public $id;  
public $TableInput = [];


public function mount()
{
  $this->User       = User::all();   
}

public function Save() 
{   
    $bel = Data::create([ 
         
        'Id'                     => $value['Id'],
        'name'                   => $value['name'],
        'data'                   => $value['data'],
    ]);
} 
} 

}
I am trying to set up localization on my Laravel Inerita (Vue.js). I know about https://github.com/mcamara/laravel-localization, but this does not support Inertia (at least I was not successful with running this on my Vue.js file) {{ __("text") }} does not work in inertia error: TypeError: _ctx.__ is not a function.
Anyway, I am using a different localization package called laravel-vue-i18n.
I am successful in using this on Vue.js, but I am having problems when setting the locale based on URL. How do I set my routes/middleware to use a nullable locale (en as default)?
File web.php
// Can be nullable locale?
Route::middleware(['setLocale'])->prefix('{locale?}')->group(function () {
  Route::resource('posts', PostController::class);
  Route::resource('comments', CommentController::class);

});

File SetLocaleMiddleware.php
class SetLocaleMiddleware
{
    public function handle($request, Closure $next, $locale = 'en')
    {
        \Log::info($locale); // Always logs as 'en' even if I add 'ja' in the URL
        \Log::info($request->route('locale')); // Locale or whatever is the text after localhost/ for some reason

        if (!in_array($locale, ['en', 'ja'])) {
            abort(400);
        }

        App::setLocale($locale);

        return $next($request);
    }
}

File app/Kernel.php
protected $middlewareAliases = [
    'setLocale' => \App\Http\Middleware\SetLocaleMiddleware::class,
];

Expected results:
// Set application language to Japanese
http://localhost/ja
http://localhost/ja/posts
http://localhost/ja/comments

// Set application language to English as default
http://localhost
http://localhost/posts
http://localhost/comments

Note: it does not have to be middleware.
I'm trying to get groupBy value and it giving successfully, after this I'm need only group list array
how to archive that.
my Code
$this->StudentList = Student::get();
$data =  $this->StudentList->sortBy('date', SORT_NATURAL)->groupby('date');
                 
($data);

GroupBy Result
array:14 [▼   
  "2024-01-01" => Illuminate\Database\Eloquent\Collection {#1977 ▶}
  "2024-01-02" => Illuminate\Database\Eloquent\Collection {#1978 ▶}
  "2024-01-03" => Illuminate\Database\Eloquent\Collection {#1979 ▶}
  "2024-01-04" => Illuminate\Database\Eloquent\Collection {#1980 ▶}
  "2024-01-05" => Illuminate\Database\Eloquent\Collection {#1981 ▶}
]

need this group date like this in array
array:14 [▼   
  "2024-01-01"  
  "2024-01-02"  
  "2024-01-03"  
  "2024-01-04" 
  "2024-01-05"  
]

laravel get groupBy name list
I have following models in Laravel:

User Model
Team Model
Company Model

And DB tables:
users
- id

company
- id

teams
- id
- company_id  (team can only belong to one company)

// pivot tables
company_user
- user_id
- company_id

team_user
- team_id
- user_id

I'm trying to create relationship on User Model that will get Company With teams that only belongs to that user. I can make it with joins, but I would like to have a relationship. I have tried different packages, but still can't figure it out. It's just sad 8 hours.
I have two models, List and Item, with a many-to-many relationship. Since I don’t care about getting the lists an item is in (just the items in the list), my models only define half the relationship.
class App\Models\List extends Model
{
    protected function items(): Illuminate\Database\Eloquent\Relations\BelongsToMany
    { /*...*/ }
}

Then I have a route, Route::post('/list/{item}', [ListController::class, 'item']) to which a form submits an item and some other data. The controller is responsible for retrieving the correct List model and storing the relationship & details.
class App\Http\Controllers\ListController extends Controller
{
    public function item($request, App\Models\Item $item)
    {
        /* request validation */

        $list = self::current();

        $list->items()->detach($item->id);
        $list->items()->attach($item->id, [/* other data */]);

        $list->save();

        return back();
    }

    static function current(): App\Models\List
    { /*...*/ }
}

But whenever I post to the route, I get an error saying the static items() method is not defined:

Call to undefined method App\Models\List::items()

Checks

Dumping the result of ListController::current() shows an instance of App\Models\List. This instance does have data from the database (where available).

I have verified that BelongsToMany is the correct relationship type to return.

I can return Item instances from a List instance without accessing the pivot table directly, meaning my table schema matches my model definitions.

I have verified that the request and route are passing data into the controller as expected.


I started with ->syncWithoutDetaching(), but it returns the same error. I switched to ->attach() and ->detach() for simplicity.
When using contextual information if logging in Laravel v10 (https://laravel.com/docs/10.x/logging#contextual-information), the contextual information doesn't get merged when specifying the channel name.
e.g.: This works fine:
Log::info(
   'User {user} created Thing {id}', 
   [
      'user' => auth()->user()->id,
      'id' => $thing->id
   ]
);

...produces:
[2024-01-31 08:44:23] local.INFO: User 1 created Thing 3 {"user":1,"id":3} 

However, this doesn't work:
Log::channel('mychannel')->info(
   'User {user} created Thing {id}',
   [
      'user' => auth()->user()->id,
      'id' => $thing->id
   ]
);

...as it produces:
[2024-01-31 08:36:15] local.INFO: User {user} created Thing {id} {"user":1,"id":2} 

Any idea what I'm doing wrong?
I am using PHPStan within a Laravel 10 app and have set this to quite a high level (good practice I guess) - I have run into a few errors and i'm trying to figure out the best way to resolve them.
 ------ ------------------------------------------------------------------------------------------ 
  Line   app/Actions/Reports/SetReportStatusAction.php                                             
 ------ ------------------------------------------------------------------------------------------ 
  17     Property App\Models\Report::$succeeded_at (Carbon\Carbon|null) does not accept int|null.  

<?php

declare(strict_types=1);

namespace App\Actions\Reports;

use App\Models\Report;
use Stripe\Reporting\ReportRun;

class SetReportStatusAction
{
    public function __invoke(Report $report): void
    {
        /** @var ReportRun $stripeObject */
        $stripeObject = $report->getStripeObject();
        $report->status = $stripeObject->status;
        $report->succeeded_at = $stripeObject->succeeded_at ?? null;
    }
}

Report.php
<?php

namespace App\Models;

// use statements hidden from view

class Report extends Model implements Transitionable
{
    use HasFactory, HasStates, HasStripeObject;

    protected $fillable = [
        'stripe_id',
        'report_type',
        'status',
        'parameters',
        'expires_at',
        'succeeded_at',
    ];

    protected $casts = [
        'parameters' => 'json',
        'expires_at' => 'datetime',
        'succeeded_at' => 'datetime',
    ];
}


The data succeeded_at comes from a webhook event and will be in the format similar to this - a timestamp
"succeeded_at": 1706786551

Expected outcome -
PHPStan to detect no errors with the two files in question
Actual outcome -
Recieve a phpstan error 'Property App\Models\Report::$succeeded_at (Carbon\Carbon|null) does not accept int|null.'
I have this function in a controller in laravel 10
public function change($id)
{

    DB::beginTransaction();
    try{
        $current_period=Period::where('current',true)->first();
        $current_period->current=false;
        $current_period->save();
        $new_period=Period::findOrFail($id);
        $new_period->current=true;
        $new_period->save();

        //set person's memberSince and pay_mode to what is in the person_period pivot table
        $persons=Person::all();
        $persons->each(function ($person,$key){
            global $new_period;
            //dd($new_period->id);
            $pivot=$person->periods()->where('period_id',$new_period->id)->first();
            $person->memberSince=$pivot? $pivot['memberSince']:null;
            $person->pay_mode=$pivot?$pivot['pay_mode']:null;
            $$person->save();
        });
        DB::commit();
        $result=[];
        $ps=PersonResource::collection(Person::all());
        array_push($result, $ps);
        $pr=PeriodResource::collection(all());
        array_push($result,$pr);
        return $result;

    }catch (\Exception $e) {
        DB::rollBack();
        throw $e;
    }
}

it returns an error

message   'Attempt to read property "id" on null'

on the line just behind the presently commented line
//dd($new_period->id)

when I uncomment the line it returns the same error.
When I place the uncommented line outside the each loop, it returns the correct id of $new_period confirming that outside the each loop the $new_period exists.
What am I missing here?
I'm building an admin section for a Laravel 10 app using the boilerplate Breeze routes and templates (for now) and I have a group of prefixed routes that I want to return a 404 error for in the following cases:

there is NO signed in user
if there IS a signed in user, they are not an admin

In other words, the ONLY time the prefixed routes should produce anything substantial is if the authenticated user is an admin. Otherwise, I want it to appear as the routes don't even exist.
I am at my wits end trying to return the 404 error view and status code from the middleware. I have been tinkering with the code and reading documentation for HOURS now to no avail, and yet I get the feeling the answer is right in front of me but I'm missing something.
This is code I have in the web.php routes file:
Route::prefix('admin')->middleware(['admin'])->group(function() {
    Route::get('/', [AdminDashboardController::class, 'index'])->name('admin');
});

And here's what I have in the handle() function for the admin middleware:
public function handle(Request $request, Closure $next): Response
{
    if ($request->user() === null || $request->user()->role !== 'admin') {
        return response('This page cannot be found', 404, []);
    }
    
    return $next($request);
}

This code works just fine. BUT, I want to return the 404 page and HTTP 404 status code rather than a plain text page with the response message. If I try to return anything EXCEPT the above it just seems to skip right on to the next bit of middleware. As in, it attempts to render the Breeze dashboard component as if the user was signed in, even though the user isn't signed in.
Could anybody please guide me on how I can return the 404 error page and status code in place of the current response above?
My application has Users and Groups. They are related with a pivot table. The pivot table has nullable "joined" and "left" datetimes.
How do I use Logical Grouping on a pivot table?
I've tried:
$this->belongsToMany(User::class)->wherePivot(function ($query) use ($time) {
    $query->where('joined', null)->orWhere('joined', '<=', $time);
})
// and "left"
;

and
$this->belongsToMany(User::class)->where(function ($query) use ($time) {
    $query->wherePivot('joined', null)->orWherePivot('joined', '<=', $time);
})
// and "left"
;

but neither work. The first complains about passing a function as an argument that's expected to be a string, and the second complains about wherePivot not being defined.
Am I missing something obvious?
I'm using Laravel Nova 4 (Laravel 10.43.0, PHP 8.2.8).
When using soft deletion, I get the error Column not found: 1054 Unknown column '*.deleted_at', where * is the table of the entity for which I use it.
Full SQL request in the exception:
select * from `users` where `id` = 1 and `users`.`deleted_at` is null limit 1

If I execute this query in the SQL console in PhpStorm, it will say that there is no such column, but the query itself will execute and do it correctly. An example of an implementation with a user.


Migration:
// ...
Schema::create('users', function (Blueprint $table) {
    // ...
    $table->softDeletes();
    // ...
});

Model:
// ...
class User extends Authenticatable
{
    // ...
    use SoftDeletes;
    // ...
}
why I can't bind or display data from the database going to input text field. I already add the rules just like what other said but still not luck. Please help, I stack on this part.
By the way I am using modal from question table CRUD.
LIVEWIRE COMPONENT
class ViewPromo extends Component
{

    public $questions;
    public Promo $promo;
    public Question $question;

    protected $rules = [
        'question.question_title' => 'required',
        'question.question_type' => 'required',
    ];

    public function editQuestion(Question $question) {
        $this->question = $question;
    }

    public function mount(Promo $promo) {
        $this->promo = $promo;
        $this->questions = $this->promo->questions()->get();
    }

    public function render()
    {
        return view('livewire.admin.promos.view-promo')->extends('layouts.app')->section('contents');
    }
}

LIVEWIRE BLADE FILE
<div>
    <x-label for="question_title">Title</x-label>
    <x-input-text wire:model.defer="question.question_title" id="question_title"></x-input-text>
</div>

<div>
    <x-label for="question_type">Type</x-label>
    <x-select wire:model.defer="question.question_type" id="question_type">
        <option value="single_select" @if($question->question_type == 'single_select') selected @endif>Single select</option>
        <option value="multiple_select" @if($question->question_type == 'multiple_select') selected @endif>Multiple select</option>
    </x-select>
</div>

BUTTON FROM THE LIST
<x-button wire:click="editQuestion({{ $question->id }})" data-modal-target="edit-default-modal" data-modal-toggle="edit-default-modal" >Edit</x-button>

I want to display record from the database going to the input fields.
I've got a long-running Laravel app with a traditional form in a blade view. Inside of this form I want to start to include a couple Livewire components that can refresh and submit data independent of the form. Is this possible?
For testing purposes I've created this simple component and nested it within the existing <form> on the page..
<div>
    Time: {{ time() }}
    <button wire:click="$refresh">Refresh</button>
</div>

But, clicking the button doesn't refresh the component, and instead submits the form.
I have a Laravel store project that I am confused to develop my products database. My store products are clothes, shoes, pants, laptops, phones, headphones, etc.
Hello friends, good time
This database is for the products of my store:
database photo
But as long as I have products like shoes and clothes it works correctly and optimally because they have many options, for example these are the options for product_id=3 which is a dress in the product_options table:



option::1
option::2
option::3




color_id:8
color_id:8
color_id:9


size_id: 3
size_id:5
size_id:5


price: 25
price: 20
price: 20


stock: 5
stock: 9
stock: 8



But for products such as phones, laptops, etc., which have only one option and do not have color_id and size_id at all. I don't know what to do. please help. For example, these are the options for product_id=5, which is a laptop in the product_options table:



option::1




color_id:null


size_id: null


price: 50


stock: 5
I was trying to print array inside a foreach loop in following way:
@foreach($response['results'] as $row)
    <tr>
       <td>
         @foreach($row['status'] as $r)
            Status-  {{$r['groupName']}}   //  it shows above error on this line
         @endforeach
       </td>
       <td>{{$row['from'] - $row['sentAt']}}</td>
       <td>{{$row['to'] - $row['doneAt']}}</td>
    </tr>
@endforeach

I have checked in every response and I have got status value on each response. Here is my array response:
"results" => array:14 [▼
      0 => array:13 [▼
        "messageSegments" => array:3 [▶]
        "sentAt" => "2024-02-23T04:41:01.881Z"
        "doneAt" => "2024-02-23T04:41:03.267Z"
        "mmsCount" => 3
        "mccMnc" => "310260"
        "price" => array:2 [▶]
        "status" => array:5 [▼
          "groupId" => 3
          "groupName" => "DELIVERED"
          "id" => 5
          "name" => "DELIVERED_TO_HANDSET"
          "description" => "Message delivered to handset"
        ]
        "error" => array:5 [▼
          "groupId" => 0
          "groupName" => "OK"
          "id" => 0
          "name" => "NO_ERROR"
          "description" => "No Error"
        ]
        "applicationId" => "default"
      ]
      1 => array:13 [▶]
      2 => array:14 [▶]
      3 => array:14 [▶]

But it shows following error :

Trying to access array offset on value of type int

What could be possible error behind that and how to solve it?
I have tried this in my migration but it does not work as expected.
$table->string('key')->primary()->index();
I also tried to use chatgpt but no solutions were correct. So I hit brick wall debugging, I know its something obvious I am missing.
I am building a website in Laravel and need to use a different domain for each language.
Currently I'm using mcamara/laravel-localization for the localization.
For example:

EN => my-english-website.com
NL => my-dutch-website.com

It seems like using different domains is not something that is supported by default.
Has someone run into this issue and knows how to solve this?
I recently installed Laravel Framework 10.43.0 and then installed Laravel Breeze into that, which created a bunch of new files, including resources/views/layouts/navigation.blade.php. In that file there's this:
<!-- Navigation Links -->
<div class="hidden space-x-8 sm:-my-px sm:ms-10 sm:flex">
    <x-nav-link :href="route('dashboard')" :active="request()->routeIs('dashboard')">
        {{ __('Dashboard') }}
    </x-nav-link>
</div>

I can add new nav links by adding new x-nav-link elements but my question is...  what are the valid : attributes for x-nav-link? There's :href and :active...  anything else?
I ask because I'd like to make a nav link appear conditionally based on whether or not you're an admin for the site and I'm curious if there's a built in way to do that with the x-nav-link element.
I've been building a mail template based on the published files you get from php artisan vendor:publish --tag=laravel-notifications
And I've successfully edited the message layout to include a powered-by message, however this piece does not use a variable.
Now I'm stuck trying to add a unique unsubscribe url to just above (see picture below) this powered-by but I'm unable to pass it "upwards" to the vendor template message.blade.php
This is part is from my toMail() function from the Notification which is ultimately called by a $user->notify(new Reminder(..)) function
return (new MailMessage())
    ->markdown('emails.reminder', ['unsubscribe_url' => 'custom_url_here'])

This is the editted message.blade.php file
<x-mail::layout>

{{-- Body --}}
{{ $slot }}

{{-- Subcopy --}}
@isset($subcopy)
<x-slot:subcopy>
    <x-mail::subcopy>
        {{ $subcopy }}
    </x-mail::subcopy>
</x-slot:subcopy>
@endisset

{{-- Footer --}}
<x-slot:footer>

    <x-mail::footer>
        <a href="{{ $unsubscribe_url }}">Unsubscribe here.</a>
    </x-mail::footer>

    <x-mail::powered-by />

    <x-mail::footer>
        © {{ date('Y') }} {{ config('app.name') }}. @lang('All rights reserved.')
    </x-mail::footer>
</x-slot:footer>
</x-mail::layout>

I've tried to use functions like extends, yield, include, ... inside the emails.reminder blade template
Also tried different ways of adressing the vendor template to no luck.
@extends('vendor.mail.html.message',[
    'unsubscribe_url' => $unsubscribe_url,
])

@yield('vendor.mail.html.message',[
    'unsubscribe_url' => $unsubscribe_url,
])

@include('vendor.mail.html.message',[
    'unsubscribe_url' => $unsubscribe_url,
])

@extends('x-mail::message',[
    'unsubscribe_url' => $unsubscribe_url,
])

@extends('x-slot:message',[
    'unsubscribe_url' => $unsubscribe_url,
])

@extends('x-mail::footer',[
    'unsubscribe_url' => $unsubscribe_url,
])

@extends('x-slot:footer',[
    'unsubscribe_url' => $unsubscribe_url,
])

@extends('mail::html.message',[
    'unsubscribe_url' => $unsubscribe_url,
])

@extends('mail::text.message',[
    'unsubscribe_url' => $unsubscribe_url,
])

The picture as mentioned above: