Skip to content

Commit

Permalink
added slug edit custom
Browse files Browse the repository at this point in the history
  • Loading branch information
A1Gard committed Apr 12, 2024
1 parent 36bafb9 commit d73aaac
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 6 deletions.
13 changes: 11 additions & 2 deletions resources/views/admin/category/categoryForm.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,23 @@
@csrf

<div class="form-group row">
<div class="col-md-8 mt-3">
<div class="col-md-6 mt-3">
<label for="name">
{{__('Category name')}}
</label>
<input name="name" type="text" class="form-control @error('name') is-invalid @enderror"
placeholder="{{__('Category name')}}" value="{{old('name',$ccat->name??null)}}"/>
</div>
<div class="col-md-8 mt-3">

<div class="col-md-6 mt-3">
<label for="slug">
{{__('Slug')}}
</label>
<input name="slug" type="text" class="form-control @error('slug') is-invalid @enderror"
placeholder="{{__('Slug')}}" value="{{old('slug',$ccat->slug??null)}}"/>
</div>

<div class="col-md-12 mt-3">
<label for="subtitle">
{{__('Subtitle')}}
</label>
Expand Down
7 changes: 7 additions & 0 deletions resources/views/admin/clip/clipForm.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
placeholder="{{__('Title')}}" value="{{old('title',$clip->title??null)}}"/>
</div>
</div>
<div class="col-md-12 mt-3">
<label for="slug">
{{__('Slug')}}
</label>
<input name="slug" type="text" class="form-control @error('slug') is-invalid @enderror"
placeholder="{{__('Slug')}}" value="{{old('slug',$clip->slug??null)}}"/>
</div>
<div class="col-md-12 mt-3">
<div class="form-group">
<label for="body">
Expand Down
9 changes: 9 additions & 0 deletions resources/views/admin/gallery/galleryForm.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@
placeholder="{{__('Title')}}" value="{{old('title',$gallery->title??null)}}"/>
</div>
</div>

<div class="col-md-12 mt-3">
<label for="slug">
{{__('Slug')}}
</label>
<input name="slug" type="text" class="form-control @error('slug') is-invalid @enderror"
placeholder="{{__('Slug')}}" value="{{old('slug',$gallery->slug??null)}}"/>
</div>

<div class="col-md-12 mt-3">
<div class="form-group">
<label for="description">
Expand Down
7 changes: 7 additions & 0 deletions resources/views/admin/post/postForm.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ class="form-control @error('title') is-invalid @enderror"
placeholder="{{__('Title')}}" value="{{old('title',$posts->title??null)}}"/>
</div>
</div>
<div class="col-md-12 mt-3">
<label for="slug">
{{__('Slug')}}
</label>
<input name="slug" type="text" class="form-control @error('slug') is-invalid @enderror"
placeholder="{{__('Slug')}}" value="{{old('slug',$posts->slug??null)}}"/>
</div>
<div class="col-md-12 mt-3">
<div class="form-group">
<label for="subtitle">
Expand Down
8 changes: 7 additions & 1 deletion src/Controllers/Admin/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ public function __construct()
public function createOrUpdate(Category $cat, CategorySaveRequest $request)
{
$cat->name = $request->input('name');
$cat->slug = \StarterKit::slug($request->input('name'));
// @if ()
if (!$request->has('slug') || $request->input('slug') == null){
$cat->slug = \StarterKit::slug($request->input('name'));
}else{
$cat->slug = \StarterKit::slug($request->input('slug'));
}

$cat->description = $request->input('description');
$cat->subtitle = $request->input('subtitle');
$cat->parent_id = $request->input('parent') == '' ? null : $request->input('parent');
Expand Down
6 changes: 5 additions & 1 deletion src/Controllers/Admin/ClipController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ public function bulk(Request $request)
public function createOrUpdate(Clip $clip, ClipSaveRequest $request)
{
$clip->title = $request->input('title');
$clip->slug = \StarterKit::slug($request->input('title'));
if (!$request->has('slug') || $request->input('slug') == null){
$clip->slug = \StarterKit::slug($request->input('name'));
}else{
$clip->slug = \StarterKit::slug($request->input('slug'));
}
$clip->body = $request->input('body');
$clip->active = $request->has('active');
$clip->user_id = auth()->id();
Expand Down
7 changes: 6 additions & 1 deletion src/Controllers/Admin/GalleryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ public function updatetitle(\Illuminate\Http\Request $request)
public function createOrUpdate(Gallery $gallery, GallerySaveRequest $request)
{
$gallery->title = $request->input('title');
$gallery->slug = \StarterKit::slug($request->input('title'));
if (!$request->has('slug') || $request->input('slug') == null){
$gallery->slug = \StarterKit::slug($request->input('name'));
}else{
$gallery->slug = \StarterKit::slug($request->input('slug'));
}

$gallery->description = $request->input('description');
$gallery->status = $request->input('status');
$gallery->user_id = auth()->id();
Expand Down
6 changes: 5 additions & 1 deletion src/Controllers/Admin/PostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ public function createOrUpdate(Post $post, PostSaveRequest $request)
$dt = new TDate();

$post->title = $request->input('title');
$post->slug = \StarterKit::slug($request->input('title'));
if (!$request->has('slug') || $request->input('slug') == null){
$post->slug = \StarterKit::slug($request->input('name'));
}else{
$post->slug = \StarterKit::slug($request->input('slug'));
}
$post->body = $request->input('body');
$post->subtitle = $request->input('subtitle');
$post->status = $request->input('status');
Expand Down
5 changes: 5 additions & 0 deletions src/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ class Post extends Model implements HasMedia

public $translatable = ['title','subtitle','body'];


public function category(){
return $this->belongsTo(Category::class);
}

public function categories()
{
return $this->belongsToMany(Category::class);
Expand Down

0 comments on commit d73aaac

Please sign in to comment.