diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index a6d1341..41db4ef 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -887,6 +887,13 @@ function success($data = null, $message = null, $meta = [], $og = [], $twitter = ]); } +/** + * @param $errors + * @param $status + * @param $message + * @param $data + * @return \Illuminate\Http\JsonResponse + */ function errors($errors, $status = 422, $message = null, $data = null) { return response()->json([ @@ -896,3 +903,8 @@ function errors($errors, $status = 422, $message = null, $data = null) "data" => $data, ], $status); } + +function readable($text) +{ + return ucfirst(trim(str_replace(['-','_'],' ',$text))); +} diff --git a/app/Http/Controllers/Admin/PostController.php b/app/Http/Controllers/Admin/PostController.php index 0dd3f86..735f459 100644 --- a/app/Http/Controllers/Admin/PostController.php +++ b/app/Http/Controllers/Admin/PostController.php @@ -57,7 +57,7 @@ class PostController extends XController $post->status = $request->input('status'); $post->group_id = $request->input('group_id'); $post->user_id = auth()->id(); - $post->is_pinned = $request->has('is_pinned'); + $post->is_pinned = $request->has('is_pin'); $post->icon = $request->input('icon'); if ($post->hash == null) { diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index 75daeeb..e2f3ff4 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -11,59 +11,75 @@ use Spatie\Tags\Tag; class ClientController extends Controller { + + public $paginate = 10; + // - public function welcome(){ + public function welcome() + { $area = 'index'; $title = config('app.name'); $subtitle = getSetting('subtitle'); - return view('client.welcome',compact('area','title','subtitle')); + return view('client.welcome', compact('area', 'title', 'subtitle')); } - public function post(Post $post){ + public function post(Post $post) + { $area = 'post'; $title = $post->title; $subtitle = $post->subtitle; $post->increment('view'); - return view('client.post',compact('area','post','title','subtitle')); + return view('client.post', compact('area', 'post', 'title', 'subtitle')); + } + + public function posts() + { + $area = 'posts-list'; + $title = __("Posts list"); + $subtitle = ''; + $posts = Post::where('status', 1)->orderByDesc('id')->paginate($this->paginate); + return view('client.posts', compact('area', 'posts', 'title', 'subtitle')); } - public function tag($slug){ + public function tag($slug) + { - $tag = Tag::where('slug->'.config('app.locale'),'like',$slug)->first(); + $tag = Tag::where('slug->' . config('app.locale'), 'like', $slug)->first(); return $tag; } - public function submitComment(Request $request){ + public function submitComment(Request $request) + { $request->validate([ - 'commentable_type' => ['required','string','min:5'], - 'commentable_id' => ['required','integer'], - 'message' => ['required','string','min:5'], - 'parent_id' => ['nullable','integer'], + 'commentable_type' => ['required', 'string', 'min:5'], + 'commentable_id' => ['required', 'integer'], + 'message' => ['required', 'string', 'min:5'], + 'parent_id' => ['nullable', 'integer'], ]); $comment = new Comment(); - if (!auth()->check() && !auth('customer')->check()){ + if (!auth()->check() && !auth('customer')->check()) { $request->validate([ - 'name' => ['required','string','min:2'], - 'email' => ['required','email'], + 'name' => ['required', 'string', 'min:2'], + 'email' => ['required', 'email'], ]); $comment->name = $request->name; $comment->email = $request->email; $comment->status = 0; - }else{ - if (auth()->check() ){ - $comment->commentator_type = User::class; - $comment->commentator_id = auth()->id(); + } else { + if (auth()->check()) { + $comment->commentator_type = User::class; + $comment->commentator_id = auth()->id(); $comment->status = 1; - }else{ - $comment->commentator_type = Customer::class; - $comment->commentator_id = auth('customer')->id(); + } else { + $comment->commentator_type = Customer::class; + $comment->commentator_id = auth('customer')->id(); $comment->status = 0; } } - $comment->parent_id = $request->input('parent_id',null); + $comment->parent_id = $request->input('parent_id', null); $comment->body = $request->input('message'); $comment->commentable_type = $request->input('commentable_type'); $comment->commentable_id = $request->input('commentable_id'); @@ -73,7 +89,8 @@ class ClientController extends Controller return redirect()->back()->with(['message' => __('Your comment has been submitted')]); } - public function search(Request $request){ + public function search(Request $request) + { } } diff --git a/app/Http/Requests/PostSaveRequest.php b/app/Http/Requests/PostSaveRequest.php index ba1b23e..c9cc74f 100644 --- a/app/Http/Requests/PostSaveRequest.php +++ b/app/Http/Requests/PostSaveRequest.php @@ -25,8 +25,8 @@ class PostSaveRequest extends FormRequest 'title' => ['required', 'string', 'max:255', 'min:2'], 'subtitle' => ['nullable', 'string', 'max:2048'], 'body' => ['required', 'string', 'min:5'], - 'status' => ['required', 'boolean'], - 'is_pin' => ['nullable', 'boolean'], + 'status' => ['required'], + 'is_pin' => ['nullable'], 'image' => ['nullable', 'image', 'mimes:jpeg,png,jpg,gif,svg', 'max:2048'], 'icon' => ['nullable', 'string', 'min:3'], 'group_id' => ['required', 'exists:groups,id'], diff --git a/app/Models/Post.php b/app/Models/Post.php index a602166..2598718 100644 --- a/app/Models/Post.php +++ b/app/Models/Post.php @@ -102,7 +102,7 @@ class Post extends Model implements HasMedia } public function mainGroup(){ - return $this->belongsTo(Group::class); + return $this->belongsTo(Group::class,'group_id'); } public function attachs(){ diff --git a/resources/views/admin/areas/area-list.blade.php b/resources/views/admin/areas/area-list.blade.php index d14b961..30f8fe5 100644 --- a/resources/views/admin/areas/area-list.blade.php +++ b/resources/views/admin/areas/area-list.blade.php @@ -1,3 +1,4 @@ + @extends('layouts.app') @section('title') @@ -9,7 +10,7 @@
@endforeach diff --git a/resources/views/admin/posts/post-form.blade.php b/resources/views/admin/posts/post-form.blade.php index d1471e4..224cf9d 100644 --- a/resources/views/admin/posts/post-form.blade.php +++ b/resources/views/admin/posts/post-form.blade.php @@ -175,9 +175,8 @@
+ {{$post->subtitle}}
+
+
+ {{__("Read more")}}
+
+