From ee075c543e0b74b9f6e1e3be089433f0a326d14b Mon Sep 17 00:00:00 2001 From: Marley Rae Date: Wed, 27 Apr 2022 18:57:21 -0700 Subject: [PATCH] owned index --- app/Http/Controllers/OwnedController.php | 14 +---- app/Models/Collective.php | 58 ++++++++++--------- app/Models/Joined.php | 7 +-- app/Models/Owned.php | 8 +++ app/Traits/Ownable.php | 13 +++++ database/factories/OwnedFactory.php | 2 +- public/css/admin/style.css | 6 +- resources/sass/admin/_base.scss | 2 +- resources/views/admin/layout.blade.php | 4 +- resources/views/admin/owned/index.blade.php | 11 ++++ .../views/admin/sessions/create.blade.php | 4 +- .../views/components/form/buttons.blade.php | 4 +- routes/web.php | 38 ++++++------ 13 files changed, 100 insertions(+), 71 deletions(-) create mode 100644 app/Traits/Ownable.php create mode 100644 resources/views/admin/owned/index.blade.php diff --git a/app/Http/Controllers/OwnedController.php b/app/Http/Controllers/OwnedController.php index dad7b8d..0f96309 100644 --- a/app/Http/Controllers/OwnedController.php +++ b/app/Http/Controllers/OwnedController.php @@ -15,7 +15,7 @@ class OwnedController extends Controller */ public function index() { - // + return view('admin.owned.index'); } /** @@ -25,62 +25,50 @@ public function index() */ public function create() { - // } /** * Store a newly created resource in storage. * - * @param \App\Http\Requests\StoreOwnedRequest $request * @return \Illuminate\Http\Response */ public function store(StoreOwnedRequest $request) { - // } /** * Display the specified resource. * - * @param \App\Models\Owned $owned * @return \Illuminate\Http\Response */ public function show(Owned $owned) { - // } /** * Show the form for editing the specified resource. * - * @param \App\Models\Owned $owned * @return \Illuminate\Http\Response */ public function edit(Owned $owned) { - // } /** * Update the specified resource in storage. * - * @param \App\Http\Requests\UpdateOwnedRequest $request - * @param \App\Models\Owned $owned * @return \Illuminate\Http\Response */ public function update(UpdateOwnedRequest $request, Owned $owned) { - // } /** * Remove the specified resource from storage. * - * @param \App\Models\Owned $owned * @return \Illuminate\Http\Response */ public function destroy(Owned $owned) { - // } } diff --git a/app/Models/Collective.php b/app/Models/Collective.php index ad36276..6971517 100644 --- a/app/Models/Collective.php +++ b/app/Models/Collective.php @@ -3,23 +3,24 @@ namespace App\Models; use Illuminate\Database\Eloquent\Casts\Attribute; +use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use Laravel\Sanctum\HasApiTokens; class Collective extends Authenticatable { - use HasApiTokens, Notifiable; + use HasApiTokens; + use Notifiable; /* @var array */ - + protected $fillable = [ 'name', 'email', 'password', ]; - /* @var array */ protected $hidden = [ @@ -33,33 +34,38 @@ class Collective extends Authenticatable 'email_verified_at' => 'datetime', ]; -/* --------------------------------------------------------------------------- relationships ---- */ + /* ----------------------------------------------------------------------- relationships ---- */ - public function joined() - { - return $this->hasMany(Joined::class); - } + public function joined() : HasMany + { + return $this->hasMany(Joined::class); + } -/* -------------------------------------------------------------------------------- password ---- */ + public function owned() : HasMany + { + return $this->hasMany(Owned::class); + } - protected function password() : Attribute - { - return Attribute::make( - set: fn ($value) => bcrypt($value), - ); - } + /* ---------------------------------------------------------------------------- password ---- */ -/* ----------------------------------------------------------------------------------- store ---- */ + protected function password() : Attribute + { + return Attribute::make( + set: fn ($value) => bcrypt($value), + ); + } - public static function store(array $validated) : Collective - { - $collective = new Collective(); - $collective->title = $validated['title']; - $collective->name = $validated['name']; - $collective->email = $validated['email']; - $collective->password = $validated['password']; - $collective->save(); + /* ------------------------------------------------------------------------------- store ---- */ - return $collective; - } + public static function store(array $validated) : Collective + { + $collective = new Collective(); + $collective->title = $validated['title']; + $collective->name = $validated['name']; + $collective->email = $validated['email']; + $collective->password = $validated['password']; + $collective->save(); + + return $collective; + } } diff --git a/app/Models/Joined.php b/app/Models/Joined.php index b031d8b..4c436f6 100644 --- a/app/Models/Joined.php +++ b/app/Models/Joined.php @@ -4,6 +4,7 @@ use App\Traits\Categorizable; use App\Traits\Imageable; +use App\Traits\Ownable; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -11,6 +12,7 @@ class Joined extends Model { use HasFactory; + use Ownable; use Categorizable; use Imageable; @@ -29,10 +31,7 @@ class Joined extends Model /* ----------------------------------------------------------------------- relationships ---- */ - public function collective() - { - return $this->belongsTo(Collective::class); - } + // injected by trait: collective (belongsTo) // injected by trait: categories (morph many-to-many) diff --git a/app/Models/Owned.php b/app/Models/Owned.php index 520f811..d5988c6 100644 --- a/app/Models/Owned.php +++ b/app/Models/Owned.php @@ -2,12 +2,20 @@ namespace App\Models; +use App\Traits\Categorizable; +use App\Traits\Imageable; +use App\Traits\Ownable; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class Owned extends Model { use HasFactory; + use Ownable; + use Categorizable; + use Imageable; protected $table = 'owned'; + + /* ----------------------------------------------------------------------- relationships ---- */ } diff --git a/app/Traits/Ownable.php b/app/Traits/Ownable.php new file mode 100644 index 0000000..0255ae4 --- /dev/null +++ b/app/Traits/Ownable.php @@ -0,0 +1,13 @@ +belongsTo(Collective::class); + } +} diff --git a/database/factories/OwnedFactory.php b/database/factories/OwnedFactory.php index 0f15cb4..dccbd4b 100644 --- a/database/factories/OwnedFactory.php +++ b/database/factories/OwnedFactory.php @@ -35,7 +35,7 @@ public function definition() 'status' => $statuses->random(), 'slug' => $this->faker->slug(2, false), 'title' => $this->faker->words(3, true), - 'image' => $this->faker->image(), + 'image' => $this->faker->imageUrl(), 'hold_member_updates' => $this->faker->boolean(), 'notify_pending' => $this->faker->boolean(), 'sort_by' => 'country', diff --git a/public/css/admin/style.css b/public/css/admin/style.css index 3f2c92b..e1820ea 100644 --- a/public/css/admin/style.css +++ b/public/css/admin/style.css @@ -13,7 +13,7 @@ .form__input--file::-webkit-file-upload-button { -webkit-transition: background-color 0.4s, border-color 0.4s, color 0.4s; transition: background-color 0.4s, border-color 0.4s, color 0.4s; } -.pagination__item, .pagination__item--disabled, .pagination__item--active, .btn--table, .l-page-nav__link, .form__input--file::file-selector-button, .form__btn { +.pagination__item, .pagination__item--disabled, .pagination__item--active, .btn--table, .l-page-nav__link, .form__input--file::file-selector-button, .input--btn { border: 1px solid #7874ff; padding: 5px 10px; margin-right: 5px; @@ -32,7 +32,7 @@ .form__input--file:hover::-webkit-file-upload-button { -webkit-transition: background-color 0.4s, border-color 0.4s, color 0.4s; transition: background-color 0.4s, border-color 0.4s, color 0.4s; } -.pagination__item:hover, .pagination__item--disabled:hover, .pagination__item--active:hover, .btn--table:hover, .l-page-nav__link:hover, .form__input--file:hover::file-selector-button, .form__btn:hover { +.pagination__item:hover, .pagination__item--disabled:hover, .pagination__item--active:hover, .btn--table:hover, .l-page-nav__link:hover, .form__input--file:hover::file-selector-button, .input--btn:hover { border-color: #de7cff; background-color: #f8e5ff; color: #de7cff; @@ -45,7 +45,7 @@ .form__input--file:focus::-webkit-file-upload-button { -webkit-transition: background-color 0.4s, border-color 0.4s, color 0.4s; transition: background-color 0.4s, border-color 0.4s, color 0.4s; } -.pagination__item:focus, .pagination__item--disabled:focus, .pagination__item--active:focus, .btn--table:focus, .l-page-nav__link:focus, .form__input--file:focus::file-selector-button, .form__btn:focus { +.pagination__item:focus, .pagination__item--disabled:focus, .pagination__item--active:focus, .btn--table:focus, .l-page-nav__link:focus, .form__input--file:focus::file-selector-button, .input--btn:focus { border-color: #de7cff; background-color: #f8e5ff; color: #de7cff; diff --git a/resources/sass/admin/_base.scss b/resources/sass/admin/_base.scss index c579d2a..0ca9b46 100644 --- a/resources/sass/admin/_base.scss +++ b/resources/sass/admin/_base.scss @@ -124,7 +124,7 @@ h1 { &:first-of-type { margin-top: 20px; } } -.form__btn { +.input--btn { @extend %btn; } diff --git a/resources/views/admin/layout.blade.php b/resources/views/admin/layout.blade.php index b0ef771..b8cd719 100644 --- a/resources/views/admin/layout.blade.php +++ b/resources/views/admin/layout.blade.php @@ -24,7 +24,9 @@ joined - owned + + owned + collective +@endsection + +@section('pg-title', 'Owned') + +@section('content') + +@endsection \ No newline at end of file diff --git a/resources/views/admin/sessions/create.blade.php b/resources/views/admin/sessions/create.blade.php index 668bce6..9fd2239 100644 --- a/resources/views/admin/sessions/create.blade.php +++ b/resources/views/admin/sessions/create.blade.php @@ -24,8 +24,8 @@ class="form__input--checkbox">
- - + +
diff --git a/resources/views/components/form/buttons.blade.php b/resources/views/components/form/buttons.blade.php index 75e7f09..efa1084 100644 --- a/resources/views/components/form/buttons.blade.php +++ b/resources/views/components/form/buttons.blade.php @@ -8,8 +8,8 @@ ])
- -
\ No newline at end of file diff --git a/routes/web.php b/routes/web.php index a8905ba..4f348d4 100644 --- a/routes/web.php +++ b/routes/web.php @@ -2,7 +2,9 @@ use App\Http\Controllers\CollectiveController; use App\Http\Controllers\JoinedController; +use App\Http\Controllers\OwnedController; use App\Http\Controllers\SessionsController; +use App\Models\Owned; use Illuminate\Support\Facades\Route; /* @@ -18,12 +20,9 @@ Route::redirect('/fanatic', '/fanatic/login')->middleware('guest'); Route::middleware('guest')->group(function () { - Route::get('/fanatic/login', [SessionsController::class, 'create']) - ->name('admin.sessions.create'); - Route::get('/fanatic/install', [CollectiveController::class, 'create']) - ->name('admin.collectives.create'); - Route::post('/fanatic', [CollectiveController::class, 'store']) - ->name('admin.collectives.store'); + Route::get('/fanatic/login', [SessionsController::class, 'create'])->name('admin.sessions.create'); + Route::get('/fanatic/install', [CollectiveController::class, 'create'])->name('admin.collectives.create'); + Route::post('/fanatic', [CollectiveController::class, 'store'])->name('admin.collectives.store'); }); Route::post('/fanatic', [SessionsController::class, 'store'])->name('admin.sessions.store'); @@ -32,16 +31,19 @@ Route::get('/fanatic', [CollectiveController::class, 'dashboard'])->name('admin.dashboard'); Route::delete('/fanatic', [SessionsController::class, 'destroy'])->name('admin.sessions.destroy'); - Route::get('/fanatic/joined', [JoinedController::class, 'index']) - ->name('admin.joined.index'); - Route::get('/fanatic/joined/create', [JoinedController::class, 'create']) - ->name('admin.joined.create'); - Route::post('/fanatic/joined', [JoinedController::class, 'store']) - ->name('admin.joined.store'); - Route::get('/fanatic/joined/{joined}/edit', [JoinedController::class, 'edit']) - ->name('admin.joined.edit'); - Route::patch('/fanatic/joined/{joined}', [JoinedController::class, 'update']) - ->name('admin.joined.update'); - Route::delete('/fanatic/joined/{joined}', [JoinedController::class, 'destroy']) - ->name('admin.joined.destroy'); + // joined + Route::get('/fanatic/joined', [JoinedController::class, 'index'])->name('admin.joined.index'); + Route::get('/fanatic/joined/create', [JoinedController::class, 'create'])->name('admin.joined.create'); + Route::post('/fanatic/joined', [JoinedController::class, 'store'])->name('admin.joined.store'); + Route::get('/fanatic/joined/{joined}/edit', [JoinedController::class, 'edit'])->name('admin.joined.edit'); + Route::patch('/fanatic/joined/{joined}', [JoinedController::class, 'update'])->name('admin.joined.update'); + Route::delete('/fanatic/joined/{joined}', [JoinedController::class, 'destroy'])->name('admin.joined.destroy'); + + // owned + Route::get('/fanatic/owned', [OwnedController::class, 'index'])->name('admin.owned.index'); + Route::get('/fanatic/owned/create', [OwnedController::class, 'create'])->name('admin.owned.create'); + Route::post('/fanatic/owned', [OwnedController::class, 'store'])->name('admin.owned.store'); + Route::get('/fanatic/owned/{owned}/edit', [OwnedController::class, 'edit'])->name('admin.owned.edit'); + Route::patch('/fanatic/owned/{owned}', [OwnedController::class, 'update'])->name('admin.owned.update'); + Route::delete('/fanatic/owned/{owned}', [OwnedController::class, 'destroy'])->name('admin.owned.destroy'); });