Skip to content

Commit

Permalink
Laravel Pint Style Fix
Browse files Browse the repository at this point in the history
Signed-off-by: Madhurya Dutta <97863234+madhuryadutta@users.noreply.github.com>
  • Loading branch information
madhuryadutta committed Jan 11, 2025
1 parent 1c41da2 commit 45704f2
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 43 deletions.
14 changes: 8 additions & 6 deletions app/Http/Controllers/ContentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function singleContent($id)
{
// $single_content = DB::select('select id, title, user_id, status, updated_at from contents where id=? and user_id=? and (status=? or status=?) order by updated_at desc', [$id, $current_user_id, 'Draft', 'Published']);
$single_content = DB::select('select * from contents where id=? and (status=? or status=?) order by updated_at desc', [$id, 'Draft', 'Published']);

return view('public_views.postDetails', ['single_content' => $single_content]);
}

Expand Down Expand Up @@ -45,7 +46,7 @@ public function create_post(Request $request, $id = null)
$post = $request['post_content'];
// temporary fix to image height width issue
// $updated_content_text = str_replace('<img', '<img class="my-responsive-image" ', $request['post_content']);
$updated_content_text = $request['contentToSave'];
$updated_content_text = $request['contentToSave'];
if ($id == null) {
$content = new Content;
} else {
Expand All @@ -57,14 +58,15 @@ public function create_post(Request $request, $id = null)
$content->user_id = 1;
$content->status = 'Published';
$content->save();
$resp_obj = [
'status' => 'Success',
'code' => 1,
'a' => $content
// $resp_obj = [
// 'status' => 'Success',
// 'code' => 1

// ];

];
return redirect('list_content');
}

public function edit_post(Request $request, $id)
{
$SingleContent = Content::find($id);
Expand Down
24 changes: 10 additions & 14 deletions app/Http/Controllers/EditorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

class EditorController extends Controller
{

public function upload(Request $request)
{

Expand All @@ -30,17 +29,14 @@ public function upload(Request $request)
// Store the uploaded image locally
$path = $file->store('ap-northeast-1', 'public'); // Store in the "uploads" directory locally
// Get the full URL of the file stored locally via the subdomain
$url = asset('storage/' . $path); // Use `asset` to generate the URL
$url = asset('storage/'.$path); // Use `asset` to generate the URL

}

// Return the URL to the client
return response()->json(['location' => $url]);




die();
exit();

$cdnEndpoint = config('custom.cdn');

Expand All @@ -51,7 +47,7 @@ public function upload(Request $request)
]);

$image = $request->file('upload');
$filename = time() . '.' . $image->getClientOriginalExtension();
$filename = time().'.'.$image->getClientOriginalExtension();

// Resize the image
$resizedImage = Image::make($image->path());
Expand All @@ -60,7 +56,7 @@ public function upload(Request $request)
});

// Using Laravel's storage system to save the image
$path = 'cdn/' . $filename; // Define path within the disk
$path = 'cdn/'.$filename; // Define path within the disk

// Choose disk: local, public, or s3
// $disk = 'public'; // Example: to use the "public" disk
Expand All @@ -70,7 +66,7 @@ public function upload(Request $request)
Storage::disk($disk)->put($path, (string) $resizedImage->encode());

$CKEditorFuncNum = $request->input('CKEditorFuncNum');
$url = $cdnEndpoint . $path;
$url = $cdnEndpoint.$path;
// echo $url;
// $url = asset($path . $filenametostore);
// $url = url($path . $filenametostore);
Expand All @@ -88,21 +84,21 @@ public function upload(Request $request)

// if ($request->hasFile('upload')) {

//get filename with extension
// get filename with extension
// $filenamewithextension = $request->file('upload')->getClientOriginalName();

//get filename without extension
// get filename without extension
// $filename = pathinfo($filenamewithextension, PATHINFO_FILENAME);

//get file extension
// get file extension
// $extension = $request->file('upload')->getClientOriginalExtension();

//filename to store
// filename to store
// $filenametostore = str_replace(' ', '', $filename) . '_' . time() . '.' . $extension;
// $filenametostore = str_replace(' ', '', $filename) . '_' . time() . '.' . $extension;

$path = 'cdn/';
//Upload File
// Upload File
// $request->file('upload')->storeAs($path, $filenametostore);

// temp
Expand Down
10 changes: 2 additions & 8 deletions app/Http/Controllers/PostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ public function create()
'reactions' => ['likes' => 0, 'dislikes' => 0],
'views' => 0,
'user_id' => null,
]
],
]);
}

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
Expand All @@ -62,7 +61,6 @@ public function store(Request $request)
/**
* Display the specified resource.
*
* @param \App\Models\Post $post
* @return \Illuminate\Http\Response
*/
public function show(Post $post)
Expand All @@ -73,7 +71,6 @@ public function show(Post $post)
/**
* Show the form for editing the specified resource.
*
* @param \App\Models\Post $post
* @return \Illuminate\Http\Response
*/
public function edit(Post $post)
Expand All @@ -88,15 +85,13 @@ public function edit(Post $post)
'reactions',
'views',
'user_id',
]
],
]);
}

/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \App\Models\Post $post
* @return \Illuminate\Http\Response
*/
public function update(Request $request, Post $post)
Expand All @@ -118,7 +113,6 @@ public function update(Request $request, Post $post)
/**
* Remove the specified resource from storage.
*
* @param \App\Models\Post $post
* @return \Illuminate\Http\Response
*/
public function destroy(Post $post)
Expand Down
2 changes: 1 addition & 1 deletion database/factories/PostFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function definition()
'tags' => json_encode($this->faker->words(3)),
'reactions' => json_encode([
'likes' => $this->faker->numberBetween(0, 1000),
'dislikes' => $this->faker->numberBetween(0, 100)
'dislikes' => $this->faker->numberBetween(0, 100),
]),
'views' => $this->faker->numberBetween(0, 10000),
'user_id' => $this->faker->numberBetween(1, 100),
Expand Down
1 change: 0 additions & 1 deletion database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Database\Seeders\PostSeeder;

class DatabaseSeeder extends Seeder
{
Expand Down
5 changes: 2 additions & 3 deletions database/seeders/PostSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

namespace Database\Seeders;

use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\Post;
use Illuminate\Database\Seeder;

class PostSeeder extends Seeder
{
Expand All @@ -15,6 +14,6 @@ class PostSeeder extends Seeder
*/
public function run()
{
Post::factory(50)->create();
Post::factory(50)->create();
}
}
1 change: 1 addition & 0 deletions public/ckeditor/samples/old/sample_posteddata.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/* <body><pre>
-------------------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions resources/lang/en/dictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
return [
'welcome' => 'Welcome',
'goodbye' => 'Goodbye',
"Welcome to our website!"=> "Добро пожаловать на наш сайт!",
"BackendCMS" => "BackendCMS"
'Welcome to our website!' => 'Добро пожаловать на наш сайт!',
'BackendCMS' => 'BackendCMS',
];
3 changes: 1 addition & 2 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

use App\Http\Controllers\Api\CategoryController;
use App\Http\Controllers\HealthCheckController;
use App\Http\Controllers\PostController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\PostController;


/*
|--------------------------------------------------------------------------
Expand Down
4 changes: 0 additions & 4 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
// Route::get('view_post', [ContentController::class, 'view_post'])->name('view_post');
Route::get('single_content/{id}', [ContentController::class, 'singleContent'])->name('singleContent');



Route::get('/edit_content/{id?}', [ContentController::class, 'edit_post'])->name('editContent');

Route::get('list_content', [ContentController::class, 'listContent'])->name('listContent');
Expand Down Expand Up @@ -93,11 +91,9 @@
Route::get('/category-recycle-bin', 'viewCategory')->name('category.recycle_bin');
});


Route::get('/post-all', [ContentController::class, 'listContent'])->name('post.all');
Route::get('/post-waiting-for-approval', [ContentController::class, 'listContent'])->name('post.waiting');
Route::get('/post-archieve', [ContentController::class, 'listContent'])->name('post.archieve');
Route::get('/post-recycle-bin', [ContentController::class, 'listContent'])->name('post.recycle_bin');


Route::post('abc', [ContentController::class, 'create_post'])->name('save.content');
5 changes: 3 additions & 2 deletions tests/Feature/PostControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

namespace Tests\Feature;

use App\Models\Post;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
use App\Models\Post;

class PostControllerTest extends TestCase
{
Expand All @@ -15,12 +14,14 @@ class PostControllerTest extends TestCase
* @return void
*/
use RefreshDatabase;

public function test_example()
{
$response = $this->get('/');

$response->assertStatus(200);
}

public function test_can_list_posts()
{
Post::factory()->count(10)->create();
Expand Down

0 comments on commit 45704f2

Please sign in to comment.