mirror of
https://github.com/anna-sara/filament_inventory
synced 2025-10-27 10:57:13 +01:00
Compare commits
No commits in common. "5d1a0a77a804be1f4a2f9a4e0f68442fabe6d35e" and "521a70f9a19c62ffe8c42f9b83b47bce35172225" have entirely different histories.
5d1a0a77a8
...
521a70f9a1
9 changed files with 1 additions and 239 deletions
|
|
@ -30,7 +30,6 @@ use Filament\Infolists\Components\TextEntry;
|
||||||
use Filament\Infolists\Components\Section;
|
use Filament\Infolists\Components\Section;
|
||||||
use Filament\Tables\Contracts\HasTable;
|
use Filament\Tables\Contracts\HasTable;
|
||||||
use Filament\Tables\Concerns\InteractsWithTable;
|
use Filament\Tables\Concerns\InteractsWithTable;
|
||||||
use Filament\Infolists\Components\ImageEntry;
|
|
||||||
|
|
||||||
class Reserve extends BasePage implements HasTable
|
class Reserve extends BasePage implements HasTable
|
||||||
{
|
{
|
||||||
|
|
@ -87,7 +86,6 @@ class Reserve extends BasePage implements HasTable
|
||||||
->infolist([
|
->infolist([
|
||||||
Section::make('Game')
|
Section::make('Game')
|
||||||
->schema([
|
->schema([
|
||||||
ImageEntry::make('image'),
|
|
||||||
TextEntry::make('desc'),
|
TextEntry::make('desc'),
|
||||||
TextEntry::make('acquisition_date'),
|
TextEntry::make('acquisition_date'),
|
||||||
TextEntry::make('category.name'),
|
TextEntry::make('category.name'),
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,7 @@ use Filament\Forms\Components\TextInput;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Filament\Support\Enums\IconPosition;
|
use Filament\Support\Enums\IconPosition;
|
||||||
use Filament\Infolists\Components\TextEntry;
|
use Filament\Infolists\Components\TextEntry;
|
||||||
use Filament\Infolists\Components\ImageEntry;
|
|
||||||
use Filament\Infolists\Components\Section;
|
use Filament\Infolists\Components\Section;
|
||||||
use Illuminate\Support\Facades\Mail;
|
|
||||||
use App\Mail\ReservationCreatedUser;
|
|
||||||
use App\Mail\ReservationCreated;
|
|
||||||
|
|
||||||
|
|
||||||
class ItemResource extends Resource
|
class ItemResource extends Resource
|
||||||
|
|
@ -163,7 +159,6 @@ class ItemResource extends Resource
|
||||||
->infolist([
|
->infolist([
|
||||||
Section::make('Game')
|
Section::make('Game')
|
||||||
->schema([
|
->schema([
|
||||||
ImageEntry::make('image'),
|
|
||||||
TextEntry::make('desc'),
|
TextEntry::make('desc'),
|
||||||
TextEntry::make('acquisition_date'),
|
TextEntry::make('acquisition_date'),
|
||||||
TextEntry::make('category.name'),
|
TextEntry::make('category.name'),
|
||||||
|
|
@ -176,7 +171,6 @@ class ItemResource extends Resource
|
||||||
->hidden(fn ($record) => $record->type === "item"),
|
->hidden(fn ($record) => $record->type === "item"),
|
||||||
Section::make('Item')
|
Section::make('Item')
|
||||||
->schema([
|
->schema([
|
||||||
ImageEntry::make('image'),
|
|
||||||
TextEntry::make('desc'),
|
TextEntry::make('desc'),
|
||||||
TextEntry::make('acquisition_date'),
|
TextEntry::make('acquisition_date'),
|
||||||
TextEntry::make('category.name'),
|
TextEntry::make('category.name'),
|
||||||
|
|
@ -204,17 +198,13 @@ class ItemResource extends Resource
|
||||||
->required(),
|
->required(),
|
||||||
])
|
])
|
||||||
->action(function (array $data, Item $record): void {
|
->action(function (array $data, Item $record): void {
|
||||||
$reservation = Reserveditem::create([
|
Reserveditem::create([
|
||||||
'item_id' => $record->id,
|
'item_id' => $record->id,
|
||||||
'reserved_date' => Carbon::now(),
|
'reserved_date' => Carbon::now(),
|
||||||
'username' => $data['username'],
|
'username' => $data['username'],
|
||||||
'email' => $data['email']
|
'email' => $data['email']
|
||||||
]);
|
]);
|
||||||
Item::where('id', $record->id)->update(['reserved' => true]);
|
Item::where('id', $record->id)->update(['reserved' => true]);
|
||||||
Mail::to($data['email'])
|
|
||||||
->send(new ReservationCreatedUser($reservation));
|
|
||||||
Mail::to(env('MAIL_FROM_ADDRESS'))
|
|
||||||
->send(new ReservationCreated($reservation));
|
|
||||||
})
|
})
|
||||||
->hidden(fn ($record) => $record->reserved)
|
->hidden(fn ($record) => $record->reserved)
|
||||||
])
|
])
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,6 @@ use Filament\Resources\Pages\EditRecord;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use App\Models\Item;
|
use App\Models\Item;
|
||||||
use App\Models\Reserveditem;
|
use App\Models\Reserveditem;
|
||||||
use Illuminate\Support\Facades\Mail;
|
|
||||||
use App\Mail\Delivered;
|
|
||||||
|
|
||||||
class EditReserveditem extends EditRecord
|
class EditReserveditem extends EditRecord
|
||||||
{
|
{
|
||||||
|
|
@ -47,14 +45,6 @@ class EditReserveditem extends EditRecord
|
||||||
Reserveditem::where('id', $record->id)->delete();
|
Reserveditem::where('id', $record->id)->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($record->delivered && !$record->returned)
|
|
||||||
{
|
|
||||||
Mail::to($record->email)
|
|
||||||
->send(new Delivered($record));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getRedirectUrl(): string
|
protected function getRedirectUrl(): string
|
||||||
|
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Mail;
|
|
||||||
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Mail\Mailable;
|
|
||||||
use Illuminate\Mail\Mailables\Content;
|
|
||||||
use Illuminate\Mail\Mailables\Envelope;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Models\Reserveditem;
|
|
||||||
use App\Models\Item;
|
|
||||||
|
|
||||||
class Delivered extends Mailable
|
|
||||||
{
|
|
||||||
use Queueable, SerializesModels;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new message instance.
|
|
||||||
*/
|
|
||||||
public function __construct(public Reserveditem $reservation )
|
|
||||||
{
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the message envelope.
|
|
||||||
*/
|
|
||||||
public function envelope(): Envelope
|
|
||||||
{
|
|
||||||
return new Envelope(
|
|
||||||
subject: 'Levererad',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the message content definition.
|
|
||||||
*/
|
|
||||||
public function content(): Content
|
|
||||||
{
|
|
||||||
return new Content(
|
|
||||||
view: 'emails.user.delivered',
|
|
||||||
with: [
|
|
||||||
'reservationName' => $this->reservation->username,
|
|
||||||
'reservationDesc' => Item::where('id', $this->reservation->item_id)->pluck('desc')->first(),
|
|
||||||
'reservationEmail' => $this->reservation->email,
|
|
||||||
'reservationReturnDate' => $this->reservation->return_date->toDateString(),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the attachments for the message.
|
|
||||||
*
|
|
||||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
|
||||||
*/
|
|
||||||
public function attachments(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,60 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Mail;
|
|
||||||
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Mail\Mailable;
|
|
||||||
use Illuminate\Mail\Mailables\Content;
|
|
||||||
use Illuminate\Mail\Mailables\Envelope;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Models\Reserveditem;
|
|
||||||
use App\Models\Item;
|
|
||||||
|
|
||||||
class ReservationCreated extends Mailable
|
|
||||||
{
|
|
||||||
use Queueable, SerializesModels;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new message instance.
|
|
||||||
*/
|
|
||||||
public function __construct( public Reserveditem $reservation)
|
|
||||||
{}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the message envelope.
|
|
||||||
*/
|
|
||||||
public function envelope(): Envelope
|
|
||||||
{
|
|
||||||
return new Envelope(
|
|
||||||
subject: 'Reservation Created',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the message content definition.
|
|
||||||
*/
|
|
||||||
public function content(): Content
|
|
||||||
{
|
|
||||||
return new Content(
|
|
||||||
view: 'emails.admin.reservationcreated',
|
|
||||||
with: [
|
|
||||||
'reservationName' => $this->reservation->username,
|
|
||||||
'reservationDesc' => Item::where('id', $this->reservation->item_id)->pluck('desc')->first(),
|
|
||||||
'reservationEmail' => $this->reservation->email,
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the attachments for the message.
|
|
||||||
*
|
|
||||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
|
||||||
*/
|
|
||||||
public function attachments(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Mail;
|
|
||||||
|
|
||||||
use Illuminate\Bus\Queueable;
|
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
||||||
use Illuminate\Mail\Mailable;
|
|
||||||
use Illuminate\Mail\Mailables\Content;
|
|
||||||
use Illuminate\Mail\Mailables\Envelope;
|
|
||||||
use Illuminate\Queue\SerializesModels;
|
|
||||||
use App\Models\Item;
|
|
||||||
use App\Models\Reserveditem;
|
|
||||||
|
|
||||||
class ReservationCreatedUser extends Mailable
|
|
||||||
{
|
|
||||||
use Queueable, SerializesModels;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new message instance.
|
|
||||||
*/
|
|
||||||
public function __construct( public Reserveditem $reservation)
|
|
||||||
{}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the message envelope.
|
|
||||||
*/
|
|
||||||
public function envelope(): Envelope
|
|
||||||
{
|
|
||||||
return new Envelope(
|
|
||||||
subject: 'Reservation skapad',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the message content definition.
|
|
||||||
*/
|
|
||||||
public function content(): Content
|
|
||||||
{
|
|
||||||
return new Content(
|
|
||||||
view: 'emails.user.reservationcreated',
|
|
||||||
with: [
|
|
||||||
'reservationName' => $this->reservation->username,
|
|
||||||
'reservationDesc' => Item::where('id', $this->reservation->item_id)->pluck('desc')->first(),
|
|
||||||
'reservationEmail' => $this->reservation->email,
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the attachments for the message.
|
|
||||||
*
|
|
||||||
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
|
||||||
*/
|
|
||||||
public function attachments(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Reservation skapad</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Reservation skapad</h1>
|
|
||||||
<p>{{ $reservationName }} har reserverat {{ $reservationDesc }}</p>
|
|
||||||
<p>Mail: {{ $reservationEmail }}</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Vara levererad</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Vara levererad</h1>
|
|
||||||
<p>Du har fått {{ $reservationDesc }} levererad</p>
|
|
||||||
<p>Du ska återlämna varan {{ $reservationReturnDate }}</p>
|
|
||||||
<p>Med vänliga hälsningar</p>
|
|
||||||
<p>vBytes</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Reservation skapad</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Reservation skapad</h1>
|
|
||||||
<p>Du har reserverat {{ $reservationDesc }}</p>
|
|
||||||
<p>Ansvarig på vBytes kommer att ta kontakt med dig för att bestämma tid för överlämning.</p>
|
|
||||||
<p>Med vänliga hälsningar</p>
|
|
||||||
<p>vBytes</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Loading…
Reference in a new issue