new header

This commit is contained in:
HolgerHatGarKeineNode
2023-02-25 23:56:07 +01:00
parent 86e1ed6007
commit f0311f8230
17 changed files with 1596 additions and 296 deletions

View File

@@ -5,6 +5,7 @@ namespace App\Http\Livewire\BookCase\Form;
use App\Models\BookCase;
use App\Models\Country;
use App\Models\OrangePill;
use Illuminate\Validation\Rule;
use Livewire\Component;
use Livewire\WithFileUploads;
@@ -27,12 +28,13 @@ class OrangePillForm extends Component
public function rules()
{
return [
'orangePill.book_case_id' => 'required',
'orangePill.user_id' => 'required',
'orangePill.amount' => 'required|numeric',
'orangePill.date' => 'required|date',
'orangePill.comment' => 'required|string',
'image' => 'image|max:8192', // 8MB Max
'orangePill.book_case_id' => ['required'],
'orangePill.user_id' => ['required'],
'orangePill.amount' => ['required', 'numeric'],
'orangePill.date' => ['required', 'date'],
'orangePill.comment' => ['required', 'string'],
'image' => ['max:8192', Rule::requiredIf(!$this->orangePill->id), 'image', 'nullable'], // 8MB Max
];
}
@@ -54,10 +56,13 @@ class OrangePillForm extends Component
{
$this->validate();
$this->orangePill->save();
$this->orangePill
->addMedia($this->image)
->usingFileName(md5($this->image->getClientOriginalName()).'.'.$this->image->getClientOriginalExtension())
->toMediaCollection('images');
if ($this->image) {
$this->orangePill
->addMedia($this->image)
->usingFileName(md5($this->image->getClientOriginalName()).'.'.$this->image->getClientOriginalExtension())
->toMediaCollection('images');
}
return redirect($this->fromUrl);
}

View File

@@ -24,7 +24,11 @@ class ContentCreatorForm extends Component
return [
'image' => [Rule::requiredIf(!$this->lecturer->id), 'nullable', 'mimes:jpeg,png,jpg,gif', 'max:10240'],
'lecturer.name' => 'required',
'lecturer.name' => [
'required',
Rule::unique('lecturers', 'name')
->ignore($this->lecturer),
],
'lecturer.active' => 'boolean',
'lecturer.subtitle' => 'nullable|string',
'lecturer.intro' => 'nullable|string',

View File

@@ -2,8 +2,13 @@
namespace App\Http\Livewire\Frontend;
use App\Models\BitcoinEvent;
use App\Models\City;
use App\Models\Country;
use App\Models\CourseEvent;
use App\Models\LibraryItem;
use App\Models\MeetupEvent;
use App\Models\OrangePill;
use Illuminate\Support\Facades\Cookie;
use Illuminate\Support\Facades\Route;
use Livewire\Component;
@@ -33,7 +38,7 @@ class Header extends Component
public function mount()
{
$this->l = Cookie::get('lang') ?: config('app.locale');
if (! $this->country) {
if (!$this->country) {
$this->country = Country::query()
->where('code', $this->c)
->first();
@@ -59,20 +64,74 @@ class Header extends Component
Cookie::queue('lang', $this->l, 60 * 24 * 365);
return view('livewire.frontend.header', [
'cities' => City::query()
->select(['latitude', 'longitude'])
->get(),
'countries' => Country::query()
->select('id', 'name', 'code')
->orderBy('name')
->get()
->map(function (Country $country) {
$country->name = config('countries.emoji_flags')[str($country->code)
->upper()
->toString()].' '.$country->name;
'news' => LibraryItem::query()
->with([
'createdBy.roles',
'lecturer',
'tags',
])
->where('type', 'markdown_article')
->where('news', true)
->orderByDesc('created_at')
->take(2)
->get(),
'meetups' => MeetupEvent::query()
->with([
'meetup.users',
'meetup.city.country',
])
->where('start', '>', now())
->orderBy('start')
->take(2)
->get(),
'courseEvents' => CourseEvent::query()
->with([
'venue.city.country',
'course.lecturer',
])
->where('from', '>', now())
->orderBy('from')
->take(2)
->get(),
'libraryItems' => LibraryItem::query()
->with([
'lecturer',
])
->where('type', '<>', 'markdown_article')
->orderBy('created_at')
->take(2)
->get(),
'bitcoinEvents' => BitcoinEvent::query()
->with([
'venue',
])
->where('from', '>', now())
->orderBy('from')
->take(2)
->get(),
'orangePills' => OrangePill::query()
->with([
'user',
'bookCase',
])
->where('date', '>', now())
->orderBy('date')
->take(2)
->get(),
'cities' => City::query()
->select(['latitude', 'longitude'])
->get(),
'countries' => Country::query()
->select('id', 'name', 'code')
->orderBy('name')
->get()
->map(function (Country $country) {
$country->name = config('countries.emoji_flags')[str($country->code)
->upper()
->toString()].' '.$country->name;
return $country;
}),
return $country;
}),
]);
}
}