Skip to content

Commit

Permalink
Merge pull request #413 from nasirkhan/update
Browse files Browse the repository at this point in the history
Update docs and more
  • Loading branch information
nasirkhan authored May 8, 2023
2 parents 3e658cc + 12ca367 commit 662f249
Show file tree
Hide file tree
Showing 51 changed files with 1,261 additions and 1,107 deletions.
6 changes: 3 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
Expand All @@ -15,4 +15,4 @@ trim_trailing_whitespace = false
indent_size = 2

[docker-compose.yml]
indent_size = 4
indent_size = 4
6 changes: 3 additions & 3 deletions Modules/Article/Database/Seeders/ArticleDatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public function run()

// Populate the pivot table
Post::factory()
->has(Tag::factory()->count(rand(1, 5)))
->count(25)
->create();
->has(Tag::factory()->count(rand(1, 5)))
->count(25)
->create();
echo " Insert: posts \n\n";

// Artisan::call('auth:permission', [
Expand Down
10 changes: 5 additions & 5 deletions Modules/Article/Entities/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function setPublishedAtAttribute($value)
public function scopePublished($query)
{
return $query->where('status', '=', '1')
->where('published_at', '<=', Carbon::now());
->where('published_at', '<=', Carbon::now());
}

public function scopePublishedAndScheduled($query)
Expand All @@ -161,8 +161,8 @@ public function scopePublishedAndScheduled($query)
public function scopeFeatured($query)
{
return $query->where('is_featured', '=', 'Yes')
->where('status', '=', '1')
->where('published_at', '<=', Carbon::now());
->where('status', '=', '1')
->where('published_at', '<=', Carbon::now());
}

/**
Expand All @@ -174,8 +174,8 @@ public function scopeFeatured($query)
public function scopeRecentlyPublished($query)
{
return $query->where('status', '=', '1')
->whereDate('published_at', '<=', Carbon::today()->toDateString())
->orderBy('published_at', 'desc');
->whereDate('published_at', '<=', Carbon::today()->toDateString())
->orderBy('published_at', 'desc');
}

/**
Expand Down
40 changes: 20 additions & 20 deletions Modules/Article/Http/Controllers/Backend/CategoriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,26 +124,26 @@ public function index_data()
$data = $$module_name;

return Datatables::of($$module_name)
->addColumn('action', function ($data) {
$module_name = $this->module_name;

return view('backend.includes.action_column', compact('module_name', 'data'));
})
->editColumn('name', '<strong>{{$name}}</strong>')
->editColumn('updated_at', function ($data) {
$module_name = $this->module_name;

$diff = Carbon::now()->diffInHours($data->updated_at);

if ($diff < 25) {
return $data->updated_at->diffForHumans();
} else {
return $data->updated_at->isoFormat('LLLL');
}
})
->rawColumns(['name', 'action'])
->orderColumns(['id'], '-:column $1')
->make(true);
->addColumn('action', function ($data) {
$module_name = $this->module_name;

return view('backend.includes.action_column', compact('module_name', 'data'));
})
->editColumn('name', '<strong>{{$name}}</strong>')
->editColumn('updated_at', function ($data) {
$module_name = $this->module_name;

$diff = Carbon::now()->diffInHours($data->updated_at);

if ($diff < 25) {
return $data->updated_at->diffForHumans();
} else {
return $data->updated_at->isoFormat('LLLL');
}
})
->rawColumns(['name', 'action'])
->orderColumns(['id'], '-:column $1')
->make(true);
}

/**
Expand Down
56 changes: 28 additions & 28 deletions Modules/Article/Http/Controllers/Backend/PostsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,30 +92,30 @@ public function index_data()
$data = $$module_name;

return Datatables::of($$module_name)
->addColumn('action', function ($data) {
$module_name = $this->module_name;

return view('backend.includes.action_column', compact('module_name', 'data'));
})
->editColumn('name', function ($data) {
$is_featured = ($data->is_featured) ? '<span class="badge bg-primary">Featured</span>' : '';

return $data->name.' '.$data->status_formatted.' '.$is_featured;
})
->editColumn('updated_at', function ($data) {
$module_name = $this->module_name;

$diff = Carbon::now()->diffInHours($data->updated_at);

if ($diff < 25) {
return $data->updated_at->diffForHumans();
} else {
return $data->updated_at->isoFormat('LLLL');
}
})
->rawColumns(['name', 'status', 'action'])
->orderColumns(['id'], '-:column $1')
->make(true);
->addColumn('action', function ($data) {
$module_name = $this->module_name;

return view('backend.includes.action_column', compact('module_name', 'data'));
})
->editColumn('name', function ($data) {
$is_featured = ($data->is_featured) ? '<span class="badge bg-primary">Featured</span>' : '';

return $data->name.' '.$data->status_formatted.' '.$is_featured;
})
->editColumn('updated_at', function ($data) {
$module_name = $this->module_name;

$diff = Carbon::now()->diffInHours($data->updated_at);

if ($diff < 25) {
return $data->updated_at->diffForHumans();
} else {
return $data->updated_at->isoFormat('LLLL');
}
})
->rawColumns(['name', 'status', 'action'])
->orderColumns(['id'], '-:column $1')
->make(true);
}

/**
Expand Down Expand Up @@ -232,10 +232,10 @@ public function show($id)
$$module_name_singular = $module_model::findOrFail($id);

$activities = Activity::where('subject_type', '=', $module_model)
->where('log_name', '=', $module_name)
->where('subject_id', '=', $id)
->latest()
->paginate();
->where('log_name', '=', $module_name)
->where('subject_id', '=', $id)
->latest()
->paginate();

Log::info(label_case($module_title.' '.$module_action).' | User:'.Auth::user()->name.'(ID:'.Auth::user()->id.')');

Expand Down
48 changes: 24 additions & 24 deletions Modules/Article/Http/Middleware/GenerateMenus.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ public function handle($request, Closure $next)
$articles_menu = $menu->add('<i class="nav-icon fas fa-file-alt"></i> '.__('Article'), [
'class' => 'nav-group',
])
->data([
'order' => 81,
'activematches' => [
'admin/posts*',
'admin/categories*',
],
'permission' => ['view_posts', 'view_categories'],
]);
->data([
'order' => 81,
'activematches' => [
'admin/posts*',
'admin/categories*',
],
'permission' => ['view_posts', 'view_categories'],
]);
$articles_menu->link->attr([
'class' => 'nav-link nav-group-toggle',
'href' => '#',
Expand All @@ -37,27 +37,27 @@ public function handle($request, Closure $next)
'route' => 'backend.posts.index',
'class' => 'nav-item',
])
->data([
'order' => 82,
'activematches' => 'admin/posts*',
'permission' => ['edit_posts'],
])
->link->attr([
'class' => 'nav-link',
]);
->data([
'order' => 82,
'activematches' => 'admin/posts*',
'permission' => ['edit_posts'],
])
->link->attr([
'class' => 'nav-link',
]);
// Submenu: Categories
$articles_menu->add('<i class="nav-icon fas fa-sitemap"></i> '.__('Categories'), [
'route' => 'backend.categories.index',
'class' => 'nav-item',
])
->data([
'order' => 83,
'activematches' => 'admin/categories*',
'permission' => ['edit_categories'],
])
->link->attr([
'class' => 'nav-link',
]);
->data([
'order' => 83,
'activematches' => 'admin/categories*',
'permission' => ['edit_categories'],
])
->link->attr([
'class' => 'nav-link',
]);
})->sortBy('order');

return $next($request);
Expand Down
8 changes: 4 additions & 4 deletions Modules/Comment/Entities/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ public function setModeratedAtAttribute($value)
public function scopePublished($query)
{
return $query->where('status', '=', '1')
->whereDate('published_at', '<=', Carbon::today()
->toDateString());
->whereDate('published_at', '<=', Carbon::today()
->toDateString());
}

/**
Expand All @@ -134,8 +134,8 @@ public function scopePublished($query)
public function scopeRecentlyPublished($query)
{
return $query->where('status', '=', '1')
->whereDate('published_at', '<=', Carbon::today()->toDateString())
->orderBy('published_at', 'desc');
->whereDate('published_at', '<=', Carbon::today()->toDateString())
->orderBy('published_at', 'desc');
}

/**
Expand Down
54 changes: 27 additions & 27 deletions Modules/Comment/Http/Controllers/Backend/CommentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,31 +120,31 @@ public function index_data()
$data = $$module_name;

return Datatables::of($$module_name)
->addColumn('action', function ($data) {
$module_name = $this->module_name;
->addColumn('action', function ($data) {
$module_name = $this->module_name;

return view('backend.includes.action_column', compact('module_name', 'data'));
})
return view('backend.includes.action_column', compact('module_name', 'data'));
})
// ->editColumn('name', '<strong>{{$name}}</strong> | {{$status_formatted}}')
->editColumn('name', function ($data) {
$return_string = '<strong>'.$data->name.'</strong> | '.$data->status_formatted;

return $return_string;
})
->editColumn('updated_at', function ($data) {
$module_name = $this->module_name;

$diff = Carbon::now()->diffInHours($data->updated_at);

if ($diff < 25) {
return $data->updated_at->diffForHumans();
} else {
return $data->updated_at->isoFormat('LLLL');
}
})
->rawColumns(['name', 'action'])
->orderColumns(['id'], '-:column $1')
->make(true);
->editColumn('name', function ($data) {
$return_string = '<strong>'.$data->name.'</strong> | '.$data->status_formatted;

return $return_string;
})
->editColumn('updated_at', function ($data) {
$module_name = $this->module_name;

$diff = Carbon::now()->diffInHours($data->updated_at);

if ($diff < 25) {
return $data->updated_at->diffForHumans();
} else {
return $data->updated_at->isoFormat('LLLL');
}
})
->rawColumns(['name', 'action'])
->orderColumns(['id'], '-:column $1')
->make(true);
}

/**
Expand Down Expand Up @@ -216,10 +216,10 @@ public function show($id)
$$module_name_singular = $module_model::findOrFail($id);

$activities = Activity::where('subject_type', '=', $module_model)
->where('log_name', '=', $module_name)
->where('subject_id', '=', $id)
->latest()
->paginate();
->where('log_name', '=', $module_name)
->where('subject_id', '=', $id)
->latest()
->paginate();

Log::info(label_case($module_title.' '.$module_action).' | User:'.Auth::user()->name.'(ID:'.Auth::user()->id.')');

Expand Down
16 changes: 8 additions & 8 deletions Modules/Comment/Http/Middleware/GenerateMenus.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ public function handle($request, Closure $next)
'route' => 'backend.comments.index',
'class' => 'nav-item',
])
->data([
'order' => 85,
'activematches' => ['admin/comments*'],
'permission' => ['view_comments'],
])
->link->attr([
'class' => 'nav-link',
]);
->data([
'order' => 85,
'activematches' => ['admin/comments*'],
'permission' => ['view_comments'],
])
->link->attr([
'class' => 'nav-link',
]);
})->sortBy('order');

return $next($request);
Expand Down
18 changes: 9 additions & 9 deletions Modules/Comment/Notifications/NewCommentAdded.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public function toMail($notifiable)
$user = $notifiable;

return (new MailMessage())
->line('The introduction to the notification.')
->action('Notification Action', 'https://laravel.com')
->line('Thank you for using our application!');
->line('The introduction to the notification.')
->action('Notification Action', 'https://laravel.com')
->line('Thank you for using our application!');
}

/**
Expand All @@ -65,18 +65,18 @@ public function toSlack($notifiable)
$user = $notifiable;

return (new SlackMessage())
->success()
->from('BlueCube', ':incoming_envelope:')
->content('New Comment: '.$comment->name.' | From:'.$comment->user_name)
->attachment(function ($attachment) use ($comment) {
$attachment->title('Comment '.$comment->id, route('backend.comments.show', $comment->id))
->success()
->from('BlueCube', ':incoming_envelope:')
->content('New Comment: '.$comment->name.' | From:'.$comment->user_name)
->attachment(function ($attachment) use ($comment) {
$attachment->title('Comment '.$comment->id, route('backend.comments.show', $comment->id))
->fields([
'Post' => $comment->post_name,
'User' => $comment->user_name,
'Comment' => $comment->name,
'Status' => $comment->status_label_text,
]);
});
});
}

/**
Expand Down
Loading

0 comments on commit 662f249

Please sign in to comment.