Skip to content

Commit

Permalink
Merge pull request #47 from bedus-creation/feature/external-link
Browse files Browse the repository at this point in the history
feat: external link
  • Loading branch information
bedus-creation authored Dec 10, 2023
2 parents 10c3511 + b53f6d1 commit b613675
Show file tree
Hide file tree
Showing 144 changed files with 200 additions and 1,204 deletions.
5 changes: 2 additions & 3 deletions app/Application/Admin/Controllers/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Aammui\LaravelTaggable\Models\Category;
use Aammui\LaravelTaggable\Models\Tag;
use App\Application\Admin\Requests\ArticleStoreRequest;
use App\Domain\CMS\Models\Article;
use App\Domain\CMS\Models\Post;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
Expand Down Expand Up @@ -90,9 +89,9 @@ public function update(Request $request, $id)
*
* @param Request $request
* @param int $id
* @return void
* @return RedirectResponse
*/
public function destroy(Request $request, $id)
public function destroy(Request $request, $id): RedirectResponse
{
$article = $this->repository->findOrFail($id);
$article->delete();
Expand Down
5 changes: 3 additions & 2 deletions app/Domain/CMS/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ class Post extends Model
'slug',
'body',
'type',
'user_id'
'user_id',
'external_link'
];

public function link(): string
{
return url('posts/' . $this->id . '/' . Str::slug($this->title));
return $this->external_link ?? url('posts/' . $this->id . '/' . Str::slug($this->title));
}

public function cover($size = Responsive::SM): string
Expand Down
8 changes: 8 additions & 0 deletions app/Domain/Core/Constants/TableName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace App\Domain\Core\Constants;

class TableName
{
public const POST = 'posts';
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class LoginController extends Controller
*
* @var string
*/
protected $redirectTo = '/home';
protected $redirectTo = '/admin';

/**
* Create a new controller instance.
Expand Down
28 changes: 0 additions & 28 deletions app/Http/Controllers/HomeController.php

This file was deleted.

14 changes: 3 additions & 11 deletions app/Http/Middleware/Authenticate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,15 @@
namespace App\Http\Middleware;

use Illuminate\Auth\Middleware\Authenticate as Middleware;
use Illuminate\Http\Request;

class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
<<<<<<< HEAD
* @return string
=======
* @return string|null
>>>>>>> 89b8f88997daca671f32d4db2d12a13064c62211
*/
protected function redirectTo($request)
protected function redirectTo(Request $request): ?string
{
if (! $request->expectsJson()) {
return route('login');
}
return $request->expectsJson() ? null : route('login');
}
}
17 changes: 10 additions & 7 deletions app/Http/Middleware/RedirectIfAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,25 @@

use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Symfony\Component\HttpFoundation\Response;

class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle($request, Closure $next, $guard = null)
public function handle(Request $request, Closure $next, string ...$guards): Response
{
if (Auth::guard($guard)->check()) {
return redirect('/home');
$guards = empty($guards) ? [null] : $guards;

foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
}

return $next($request);
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Middleware/TrimStrings.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ class TrimStrings extends Middleware
/**
* The names of the attributes that should not be trimmed.
*
* @var array
* @var array<int, string>
*/
protected $except = [
'current_password',
'password',
'password_confirmation',
];
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"license": "MIT",
"require": {
"php": "^8.1",
"aammui/l9-repository": "^0.0.5",
"aammui/laravel-media": "^3.0",
"aammui/laravel-taggable": "^3.0",
"aammui/role-permission": "^3.1",
Expand Down Expand Up @@ -58,7 +59,8 @@
],
"release": [
"@php artisan ziggy:generate --env=live",
"yarn build"
"yarn build",
"yarn front:build"
],
"dev": [
"@php artisan ziggy:generate",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

use App\Domain\Core\Constants\TableName;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table(TableName::POST, function (Blueprint $table) {
$table->string('external_link')
->nullable()
->after('is_external_link');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table(TableName::POST, function (Blueprint $table) {
$table->dropColumn('external_link');
});
}
};
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build"
"build": "vite build",
"front:dev": "vite --config vite.front.config.js",
"front:build": "vite build --config vite.front.config.js"
},
"devDependencies": {
"axios": "^1.1.2",
Expand Down
31 changes: 0 additions & 31 deletions public/.htaccess

This file was deleted.

1 change: 0 additions & 1 deletion public/build/assets/apl-NWJ71v8P.js

This file was deleted.

1 change: 0 additions & 1 deletion public/build/assets/app-4YPvpFtU.css

This file was deleted.

1 change: 0 additions & 1 deletion public/build/assets/app-_4NKTRnv.css

This file was deleted.

201 changes: 0 additions & 201 deletions public/build/assets/app-vo4tqt6e.js

This file was deleted.

1 change: 0 additions & 1 deletion public/build/assets/asciiarmor-b1CB_ZQy.js

This file was deleted.

1 change: 0 additions & 1 deletion public/build/assets/asn1-8gHclKtu.js

This file was deleted.

1 change: 0 additions & 1 deletion public/build/assets/asterisk-ACCUf8tF.js

This file was deleted.

1 change: 0 additions & 1 deletion public/build/assets/brainfuck-PKU_UYGU.js

This file was deleted.

1 change: 0 additions & 1 deletion public/build/assets/clike-cN-4qqRG.js

This file was deleted.

Loading

0 comments on commit b613675

Please sign in to comment.