forked from eatvio/eatvio-infra
analysators added
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Livewire\BlogPost;
|
||||
|
||||
use Livewire\Component;
|
||||
use App\Models\BlogPost;
|
||||
use App\Models\Tag;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithFileUploads;
|
||||
use App\Models\BlogPost;
|
||||
|
||||
class Edit extends Component
|
||||
{
|
||||
@@ -15,11 +15,16 @@ class Edit extends Component
|
||||
public BlogPost $blogPost;
|
||||
|
||||
public $image = null;
|
||||
public $state = "archived";
|
||||
public $title = "";
|
||||
public $description = "";
|
||||
|
||||
public $state = 'archived';
|
||||
|
||||
public $title = '';
|
||||
|
||||
public $description = '';
|
||||
|
||||
public $tags = [];
|
||||
public $videoUrl = "";
|
||||
|
||||
public $videoUrl = '';
|
||||
|
||||
protected $listeners = ['blogPostTagAdded', 'blogPostTagRemoved'];
|
||||
|
||||
@@ -40,7 +45,7 @@ class Edit extends Component
|
||||
/* 'image' => 'required|image|max:2048', */
|
||||
'state' => 'required|in:active,archived',
|
||||
'description' => 'required|min:3',
|
||||
'videoUrl' => 'nullable|url|max:2048'
|
||||
'videoUrl' => 'nullable|url|max:2048',
|
||||
];
|
||||
|
||||
return $rules;
|
||||
@@ -56,8 +61,8 @@ class Edit extends Component
|
||||
{
|
||||
$tagToDetach = Tag::where('name', $tag)->first();
|
||||
$this->tags = collect($this->tags)
|
||||
->filter(fn($curTag) => $curTag['name'] != $tag)
|
||||
->all();
|
||||
->filter(fn ($curTag) => $curTag['name'] != $tag)
|
||||
->all();
|
||||
|
||||
$this->blogPost->tags()->detach($tagToDetach->id);
|
||||
}
|
||||
@@ -87,7 +92,7 @@ class Edit extends Component
|
||||
$post->save();
|
||||
|
||||
$tagsIds = collect($this->tags)
|
||||
->map(fn($curTag) => $curTag['id']);
|
||||
->map(fn ($curTag) => $curTag['id']);
|
||||
$post
|
||||
->tags()
|
||||
->attach($tagsIds);
|
||||
@@ -97,7 +102,6 @@ class Edit extends Component
|
||||
|
||||
return redirect()->route('blog_post.show', $post->id);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function render()
|
||||
|
||||
Reference in New Issue
Block a user