Here's your submit
method refactored to use object queries instead of array-based queries: Here's your submit
method refactored to use object queries instead of array-based queries: Here's your submit
method refactored to use object queries instead of array-based queries: Here's your submit
method refactored to use object queries instead of array-based queries: Here's your submit
method refactored to use object queries instead of array-based queries: Here's your submit
method refactored to use object queries instead of array-based queries:
public function submit()
{
$this->validate([
'title' => 'required',
'description' => 'required',
'category' => 'required',
'screenshot' => 'nullable|image|mimes:jpg,png,jpeg|max:2048',
]);
if (!Auth::check()) {
$this->validate([
'name' => 'required|string|max:255',
'email' => 'required|email|max:255',
]);
}
$screenshotPath = null;
if ($this->screenshot) {
$screenshotPath = time() . "." . $this->screenshot->getClientOriginalExtension();
$this->screenshot->storeAs('questions', $screenshotPath, 'public');
}
$slug = Str::slug($this->title);
$user = Auth::user();
if (!$user) {
$user = User::where('email', $this->email)->first();
if (!$user) {
$randomPassword = '12344321';
$user = new User();
$user->name = $this->name;
$user->email = $this->email;
$user->password = Hash::make($randomPassword);
$user->is_student = 1;
$user->save();
Mail::to($this->email)->send(new AccountCreatedMail($this->name, $this->email, $randomPassword));
}
}
$question = new Question();
$question->title = $this->title;
$question->slug = $slug;
$question->description = $this->description;
$question->category_id = $this->category;
$question->file = $screenshotPath;
$question->user_id = $user->id;
$question->save();
session()->flash('message', 'Your question has been posted successfully!');
$this->reset(['title', 'description', 'category', 'screenshot', 'name', 'email']);
$this->dispatch('resetEditor', '');
}
Already have an account? Login here
You are the student of the web
1 month agoi have some issue in downloading notes
1 month ago@asadmukhtar