Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
nasirkhan committed Jul 2, 2024
2 parents 1cde7cf + 2692578 commit b26f210
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 40 deletions.
10 changes: 5 additions & 5 deletions app/Http/Controllers/Backend/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,6 @@ public function changePassword($id)
*/
public function changePasswordUpdate(Request $request, $id)
{
$request->validate([
'password' => 'required|confirmed|min:6',
]);

$module_title = $this->module_title;
$module_name = $this->module_name;
$module_path = $this->module_path;
Expand All @@ -361,6 +357,10 @@ public function changePasswordUpdate(Request $request, $id)

$module_action = 'Change Password Update';

$request->validate([
'password' => 'required|confirmed|min:6',
]);

if (! auth()->user()->can('edit_users')) {
$id = auth()->user()->id;
}
Expand All @@ -376,7 +376,7 @@ public function changePasswordUpdate(Request $request, $id)

logUserAccess("{$module_title} {$module_action} {$$module_name_singular->name} ($id)");

return redirect("admin/{$module_name}");
return redirect("admin/{$module_name}/{$id}");
}

/**
Expand Down
39 changes: 7 additions & 32 deletions app/Models/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function getTableColumns()
break;
}

return $columns;
return json_decode(json_encode($columns));
}

/**
Expand Down Expand Up @@ -113,7 +113,7 @@ public function getStatusLabelAttribute()
}

/**
* Get Status Label.
* Get Status Label as text.
*/
public function getStatusLabelTextAttribute()
{
Expand Down Expand Up @@ -162,6 +162,11 @@ public function setSlugAttribute($value)
}
}

/**
* Boot the model and attach event listeners.
*
* @return void
*/
protected static function boot()
{
parent::boot();
Expand Down Expand Up @@ -204,36 +209,6 @@ public function setMetaTitleAttribute($value)
}
}

// /**
// * Set the 'meta description'
// * If no value submitted use the default 'meta_description'.
// *
// * @param [type]
// */
// public function setMetaDescriptionAttribute($value)
// {
// $this->attributes['meta_description'] = $value;

// if (empty($value)) {
// $this->attributes['meta_description'] = setting('meta_description');
// }
// }

// /**
// * Set the 'meta description'
// * If no value submitted use the default 'meta_description'.
// *
// * @param [type]
// */
// public function setMetaKeywordAttribute($value)
// {
// $this->attributes['meta_keyword'] = $value;

// if (empty($value)) {
// $this->attributes['meta_keyword'] = setting('meta_keyword');
// }
// }

/**
* Set the meta meta_og_image
* If no value submitted use the 'Title'.
Expand Down
68 changes: 65 additions & 3 deletions tests/Feature/BackendViewSuperAdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ protected function setUp(): void

// seed the database
$this->seed();

// Artisan::call('db:seed');
Artisan::call('laravel-starter:insert-demo-data');

// Get Super Admin
$user = User::whereId(1)->first();
Expand Down Expand Up @@ -177,7 +175,7 @@ public function test_super_admin_user_can_restore_user(): void
$this->assertSoftDeleted($user);
}

public function test_super_admin_user_can_change_password_user(): void
public function test_super_admin_user_can_view_change_password_user(): void
{
for ($i = 1; $i <= 5; $i++) {
$response = $this->get('/admin/users/'.$i.'/change-password');
Expand All @@ -186,6 +184,22 @@ public function test_super_admin_user_can_change_password_user(): void
}
}

public function test_super_admin_user_can_update_user_password(): void
{
$user_id = 5;

$response = $this
->postJson(route('backend.users.changePasswordUpdate', $user_id), [
'_method' => 'PATCH',
'password' => '123456',
'password_confirmation' => '123456',
]);

$response->assertStatus(302);

$response->assertRedirect(route('backend.users.show', $user_id));
}

/**
* Roles Test.
*
Expand Down Expand Up @@ -269,34 +283,44 @@ public function test_super_admin_user_can_view_logs_view(): void
*/
public function test_super_admin_user_can_view_posts_index(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$response = $this->get('/admin/posts');

$response->assertStatus(200);
}

public function test_super_admin_user_can_create_post(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$response = $this->get('/admin/posts/create');

$response->assertStatus(200);
}

public function test_super_admin_user_can_show_post(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$response = $this->get('/admin/posts/1');

$response->assertStatus(200);
}

public function test_super_admin_user_can_edit_post(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$response = $this->get('/admin/posts/1/edit');

$response->assertStatus(200);
}

public function test_super_admin_user_can_delete_post(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$model_id = 5;

$model = Post::find($model_id);
Expand All @@ -310,6 +334,8 @@ public function test_super_admin_user_can_delete_post(): void

public function test_super_admin_user_can_view_trashed_post(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$model_id = 5;

$model = Post::find($model_id);
Expand All @@ -326,6 +352,8 @@ public function test_super_admin_user_can_view_trashed_post(): void

public function test_super_admin_user_can_restore_trashed_post(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$model_id = 5;

$response = $this->delete('/admin/posts/'.$model_id);
Expand All @@ -343,6 +371,8 @@ public function test_super_admin_user_can_restore_trashed_post(): void

public function test_super_admin_user_can_restore_post(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$model_id = 5;

$model = Post::find($model_id);
Expand All @@ -361,34 +391,44 @@ public function test_super_admin_user_can_restore_post(): void
*/
public function test_super_admin_user_can_view_categories_index(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$response = $this->get('/admin/categories');

$response->assertStatus(200);
}

public function test_super_admin_user_can_create_category(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$response = $this->get('/admin/categories/create');

$response->assertStatus(200);
}

public function test_super_admin_user_can_show_category(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$response = $this->get('/admin/categories/1');

$response->assertStatus(200);
}

public function test_super_admin_user_can_edit_category(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$response = $this->get('/admin/categories/1/edit');

$response->assertStatus(200);
}

public function test_super_admin_user_can_delete_category(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$model_id = 5;

$model = Category::find($model_id);
Expand All @@ -402,6 +442,8 @@ public function test_super_admin_user_can_delete_category(): void

public function test_super_admin_user_can_view_trashed_category(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$model_id = 5;

$model = Category::find($model_id);
Expand All @@ -418,6 +460,8 @@ public function test_super_admin_user_can_view_trashed_category(): void

public function test_super_admin_user_can_restore_trashed_category(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$model_id = 5;

$response = $this->delete('/admin/categories/'.$model_id);
Expand All @@ -435,6 +479,8 @@ public function test_super_admin_user_can_restore_trashed_category(): void

public function test_super_admin_user_can_restore_category(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$model_id = 5;

$model = Category::find($model_id);
Expand All @@ -453,34 +499,44 @@ public function test_super_admin_user_can_restore_category(): void
*/
public function test_super_admin_user_can_view_tags_index(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$response = $this->get('/admin/tags');

$response->assertStatus(200);
}

public function test_super_admin_user_can_create_tag(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$response = $this->get('/admin/tags/create');

$response->assertStatus(200);
}

public function test_super_admin_user_can_show_tag(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$response = $this->get('/admin/tags/1');

$response->assertStatus(200);
}

public function test_super_admin_user_can_edit_tag(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$response = $this->get('/admin/tags/1/edit');

$response->assertStatus(200);
}

public function test_super_admin_user_can_delete_tag(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$model_id = 5;

$model = Tag::find($model_id);
Expand All @@ -494,6 +550,8 @@ public function test_super_admin_user_can_delete_tag(): void

public function test_super_admin_user_can_view_trashed_tag(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$model_id = 5;

$model = Tag::find($model_id);
Expand All @@ -510,6 +568,8 @@ public function test_super_admin_user_can_view_trashed_tag(): void

public function test_super_admin_user_can_restore_trashed_tag(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$model_id = 5;

$response = $this->delete('/admin/tags/'.$model_id);
Expand All @@ -527,6 +587,8 @@ public function test_super_admin_user_can_restore_trashed_tag(): void

public function test_super_admin_user_can_restore_tag(): void
{
Artisan::call('laravel-starter:insert-demo-data');

$model_id = 5;

$model = Tag::find($model_id);
Expand Down

0 comments on commit b26f210

Please sign in to comment.