Skip to content

Commit

Permalink
Merge branch 'feature/rename-news' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
arthaud-proust committed Oct 19, 2023
2 parents be760b7 + 9f2f6da commit 65b2719
Show file tree
Hide file tree
Showing 23 changed files with 122 additions and 177 deletions.
2 changes: 1 addition & 1 deletion app/Data/ParchmentData.php → app/Data/NewsData.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Spatie\TypeScriptTransformer\Attributes\TypeScript;

#[TypeScript]
class ParchmentData extends Data
class NewsData extends Data
{
public function __construct(
public int $id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

namespace App\Http\Controllers;

use App\Data\ParchmentData;
use App\Http\Requests\Parchment\StoreParchmentRequest;
use App\Http\Requests\Parchment\UpdateParchmentRequest;
use App\Models\Parchment;
use App\Data\NewsData;
use App\Http\Requests\News\StoreNewsRequest;
use App\Http\Requests\News\UpdateNewsRequest;
use App\Models\News;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Redirect;
use Inertia\Inertia;
use Inertia\Response;

class ParchmentController extends Controller
class NewsController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index(): Response
{
return Inertia::render('Parchments/Index', [
'parchments' => ParchmentData::collection(Parchment::all()),
return Inertia::render('News/Index', [
'news' => NewsData::collection(News::all()),
]);
}

Expand All @@ -28,65 +28,65 @@ public function index(): Response
*/
public function create(): Response
{
return Inertia::render('Parchments/Create');
return Inertia::render('News/Create');
}

/**
* Store a newly created resource in storage.
*/
public function store(StoreParchmentRequest $request): RedirectResponse
public function store(StoreNewsRequest $request): RedirectResponse
{
Parchment::create([
News::create([
'title' => $request->input('title'),
'summary' => $request->input('summary'),
'video' => $request->input('video'),
'lng' => $request->input('lng'),
'lat' => $request->input('lat'),
]);

return Redirect::route('parchments.index');
return Redirect::route('news.index');
}

/**
* Display the specified resource.
*/
public function show(Parchment $parchment): Response
public function show(News $news): Response
{
return Inertia::render('Parchments/Show', [
'parchment' => ParchmentData::from($parchment),
return Inertia::render('News/Show', [
'news' => NewsData::from($news),
]);
}

/**
* Show the form for editing the specified resource.
*/
public function edit(Parchment $parchment): Response
public function edit(News $news): Response
{
return Inertia::render('Parchments/Edit', [
'parchment' => $parchment,
return Inertia::render('News/Edit', [
'news' => $news,
]);
}

/**
* Update the specified resource in storage.
*/
public function update(UpdateParchmentRequest $request, Parchment $parchment): RedirectResponse
public function update(UpdateNewsRequest $request, News $news): RedirectResponse
{
$parchment->update([
$news->update([
'title' => $request->input('title'),
'summary' => $request->input('summary'),
'video' => $request->input('video'),
'lng' => $request->input('lng'),
'lat' => $request->input('lat'),
]);

return Redirect::route('parchments.index');
return Redirect::route('news.index');
}

/**
* Remove the specified resource from storage.
*/
public function destroy(Parchment $parchment): void
public function destroy(News $news): void
{
//
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace App\Http\Requests\Parchment;
namespace App\Http\Requests\News;

use Illuminate\Foundation\Http\FormRequest;

class StoreParchmentRequest extends FormRequest
class StoreNewsRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace App\Http\Requests\Parchment;
namespace App\Http\Requests\News;

use Illuminate\Foundation\Http\FormRequest;

class UpdateParchmentRequest extends FormRequest
class UpdateNewsRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Parchment.php → app/Models/News.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Parchment extends Model
class News extends Model
{
use HasFactory;

Expand Down
15 changes: 7 additions & 8 deletions app/Policies/ParchmentPolicy.php → app/Policies/NewsPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

namespace App\Policies;

use App\Models\Parchment;
use App\Models\News;
use App\Models\User;
use Illuminate\Auth\Access\Response;

class ParchmentPolicy
class NewsPolicy
{
/**
* Determine whether the user can view any models.
Expand All @@ -19,7 +18,7 @@ public function viewAny(User $user): bool
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Parchment $parchment): bool
public function view(User $user, News $news): bool
{
//
}
Expand All @@ -35,31 +34,31 @@ public function create(User $user): bool
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Parchment $parchment): bool
public function update(User $user, News $news): bool
{
//
}

/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Parchment $parchment): bool
public function delete(User $user, News $news): bool
{
//
}

/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Parchment $parchment): bool
public function restore(User $user, News $news): bool
{
//
}

/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Parchment $parchment): bool
public function forceDelete(User $user, News $news): bool
{
//
}
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class RouteServiceProvider extends ServiceProvider
*
* @var string
*/
public const HOME = '/parchments';
public const HOME = '/news';

/**
* Define your route model bindings, pattern filters, and other route configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use Illuminate\Database\Eloquent\Factories\Factory;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Parchment>
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\News>
*/
class ParchmentFactory extends Factory
class NewsFactory extends Factory
{
/**
* Define the model's default state.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('parchments', function (Blueprint $table) {
Schema::create('news', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->mediumText('summary');
$table->string('video')->nullable();
$table->double('lat');
$table->double('lng');
$table->timestamps();
});
}
Expand All @@ -24,6 +26,6 @@ public function up(): void
*/
public function down(): void
{
Schema::dropIfExists('parchments');
Schema::dropIfExists('news');
}
};

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function run(): void
]);

$this->call([
ParchmentSeeder::class,
NewsSeeder::class,
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

namespace Database\Seeders;

use App\Models\Parchment;
use App\Models\News;
use Illuminate\Database\Seeder;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;

class ParchmentSeeder extends Seeder
class NewsSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Parchment::factory()->count(50)->create();
News::factory()->count(50)->create();
}
}
10 changes: 5 additions & 5 deletions resources/js/Layouts/AuthenticatedLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const showingNavigationDropdown = ref(false);
<div class="flex">
<!-- Logo -->
<div class="shrink-0 flex items-center">
<Link :href="route('parchments.index')">
<Link :href="route('news.index')">
<ApplicationLogo
class="block h-9 w-auto fill-current text-gray-800"
/>
Expand All @@ -29,8 +29,8 @@ const showingNavigationDropdown = ref(false);

<!-- Navigation Links -->
<div class="hidden space-x-8 sm:-my-px sm:ml-10 sm:flex">
<NavLink :href="route('parchments.index')" :active="route().current('parchments.index')">
Parchemins
<NavLink :href="route('news.index')" :active="route().current('news.index')">
Informations
</NavLink>
</div>
</div>
Expand Down Expand Up @@ -112,8 +112,8 @@ const showingNavigationDropdown = ref(false);
class="sm:hidden"
>
<div class="pt-2 pb-3 space-y-1">
<ResponsiveNavLink :href="route('parchments.index')" :active="route().current('parchments.index')">
Parchemins
<ResponsiveNavLink :href="route('news.index')" :active="route().current('news.index')">
Informations
</ResponsiveNavLink>
</div>

Expand Down
Loading

0 comments on commit 65b2719

Please sign in to comment.