added create and update request for student,instructor and course crud
Cette révision appartient à :
Parent
064dbc7828
révision
d40e0fcdde
@ -5,7 +5,9 @@
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\CourseCategory;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Requests\Backend\CourseCategory\AddNewRequest;
|
||||
use App\Http\Requests\Backend\Course\CourseCategory\AddNewRequest;
|
||||
use App\Http\Requests\Backend\Course\CourseCategory\UpdateRequest;
|
||||
|
||||
use Exception;
|
||||
use File;
|
||||
|
||||
@ -73,7 +75,7 @@ public function edit($id)
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update(UpdateRequest $request, $id)
|
||||
{
|
||||
try {
|
||||
$data = CourseCategory::findOrFail($id);
|
||||
@ -90,7 +92,7 @@ public function update(Request $request, $id)
|
||||
else
|
||||
return redirect()->back()->withInput()->with('error', 'Please try again');
|
||||
} catch (Exception $e) {
|
||||
dd($e);
|
||||
// dd($e);
|
||||
return redirect()->back()->withInput()->with('error', 'Please try again');
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,8 @@
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Course;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Requests\Backend\Course\Courses\AddNewRequest;
|
||||
use App\Http\Requests\Backend\Course\Courses\UpdateRequest;
|
||||
use App\Models\CourseCategory;
|
||||
use App\Models\Instructor;
|
||||
use Exception;
|
||||
@ -34,7 +36,7 @@ public function create()
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
public function store(AddNewRequest $request)
|
||||
{
|
||||
try {
|
||||
$course = new Course;
|
||||
@ -45,7 +47,7 @@ public function store(Request $request)
|
||||
$course->category_id = $request->categoryId;
|
||||
$course->instructor_id = $request->instructorId;
|
||||
$course->type = $request->courseType;
|
||||
$course->price = $request->coursePrice;
|
||||
$course->price = $request->coursePrice;
|
||||
$course->subscription_price = $request->subscriptionPrice;
|
||||
$course->start_from = $request->start_from;
|
||||
$course->duration = $request->duration;
|
||||
@ -66,7 +68,7 @@ public function store(Request $request)
|
||||
else
|
||||
return redirect()->back()->withInput()->with('error', 'Please try again');
|
||||
} catch (Exception $e) {
|
||||
dd($e);
|
||||
// dd($e);
|
||||
return redirect()->back()->withInput()->with('error', 'Please try again');
|
||||
}
|
||||
}
|
||||
@ -93,7 +95,7 @@ public function edit($id)
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update(UpdateRequest $request, $id)
|
||||
{
|
||||
try {
|
||||
$course = Course::findOrFail(encryptor('decrypt', $id));
|
||||
@ -125,7 +127,7 @@ public function update(Request $request, $id)
|
||||
else
|
||||
return redirect()->back()->withInput()->with('error', 'Please try again');
|
||||
} catch (Exception $e) {
|
||||
dd($e);
|
||||
// dd($e);
|
||||
return redirect()->back()->withInput()->with('error', 'Please try again');
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,8 @@
|
||||
use App\Models\Material;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Requests\Backend\Course\Materials\AddNewRequest;
|
||||
use App\Http\Requests\Backend\Course\Materials\UpdateRequest;
|
||||
use App\Models\Course;
|
||||
use Exception;
|
||||
|
||||
@ -31,7 +33,7 @@ public function create()
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
public function store(AddNewRequest $request)
|
||||
{
|
||||
try {
|
||||
$material = new Material;
|
||||
@ -48,7 +50,7 @@ public function store(Request $request)
|
||||
return redirect()->back()->withInput();
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dd($e);
|
||||
// dd($e);
|
||||
$this->notice::error('Please try again');
|
||||
return redirect()->back()->withInput();
|
||||
}
|
||||
@ -75,7 +77,7 @@ public function edit($id)
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update(UpdateRequest $request, $id)
|
||||
{
|
||||
try {
|
||||
$material = Material::findOrFail(encryptor('decrypt', $id));
|
||||
@ -92,7 +94,7 @@ public function update(Request $request, $id)
|
||||
return redirect()->back()->withInput();
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dd($e);
|
||||
// dd($e);
|
||||
$this->notice::error('Please try again');
|
||||
return redirect()->back()->withInput();
|
||||
}
|
||||
|
||||
@ -5,6 +5,8 @@
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Instructor;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Requests\Backend\Instructors\AddNewRequest;
|
||||
use App\Http\Requests\Backend\Instructors\UpdateRequest;
|
||||
use App\Models\Role;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Exception;
|
||||
@ -33,10 +35,10 @@ public function create()
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
public function store(AddNewRequest $request)
|
||||
{
|
||||
try {
|
||||
$instructor = new Instructor;
|
||||
$instructor = new Instructor;
|
||||
$instructor->name_en = $request->fullName_en;
|
||||
$instructor->name_bn = $request->fullName_bn;
|
||||
$instructor->contact_en = $request->contactNumber_en;
|
||||
@ -59,7 +61,7 @@ public function store(Request $request)
|
||||
else
|
||||
return redirect()->back()->withInput()->with('error', 'Please try again');
|
||||
} catch (Exception $e) {
|
||||
dd($e);
|
||||
// dd($e);
|
||||
return redirect()->back()->withInput()->with('error', 'Please try again');
|
||||
}
|
||||
}
|
||||
@ -85,7 +87,7 @@ public function edit($id)
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update(UpdateRequest $request, $id)
|
||||
{
|
||||
try {
|
||||
$instructor = Instructor::findOrFail(encryptor('decrypt', $id));
|
||||
|
||||
@ -5,11 +5,12 @@
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Student;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Requests\Backend\Students\AddNewRequest;
|
||||
use App\Http\Requests\Backend\Students\UpdateRequest;
|
||||
use App\Models\Role;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use File;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class StudentController extends Controller
|
||||
{
|
||||
@ -34,7 +35,7 @@ public function create()
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*/
|
||||
public function store(Request $request)
|
||||
public function store(AddNewRequest $request)
|
||||
{
|
||||
try {
|
||||
$student = new Student();
|
||||
@ -61,7 +62,7 @@ public function store(Request $request)
|
||||
else
|
||||
return redirect()->back()->withInput()->with('error', 'Please try again');
|
||||
} catch (Exception $e) {
|
||||
dd($e);
|
||||
// dd($e);
|
||||
return redirect()->back()->withInput()->with('error', 'Please try again');
|
||||
}
|
||||
}
|
||||
@ -88,7 +89,7 @@ public function edit($id)
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update(UpdateRequest $request, $id)
|
||||
{
|
||||
try {
|
||||
|
||||
@ -116,7 +117,7 @@ public function update(Request $request, $id)
|
||||
else
|
||||
return redirect()->back()->withInput()->with('error', 'Please try again');
|
||||
} catch (Exception $e) {
|
||||
dd($e);
|
||||
// dd($e);
|
||||
return redirect()->back()->withInput()->with('error', 'Please try again');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Backend\CourseCategory;
|
||||
namespace App\Http\Requests\Backend\Course\CourseCategory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
@ -11,7 +11,7 @@ class AddNewRequest extends FormRequest
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Backend\CourseCategory;
|
||||
namespace App\Http\Requests\Backend\Course\CourseCategory;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
@ -11,7 +11,7 @@ class UpdateRequest extends FormRequest
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -22,7 +22,7 @@ public function authorize(): bool
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
'category_name' => 'required|max:255'
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/Backend/Course/Courses/AddNewRequest.php
Fichier normal
30
app/Http/Requests/Backend/Course/Courses/AddNewRequest.php
Fichier normal
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Backend\Course\Courses;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class AddNewRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'courseTitle_en'=> 'required|max:255',
|
||||
'categoryId'=> 'required|max:3',
|
||||
'instructorId'=> 'required|max:3',
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/Backend/Course/Courses/UpdateRequest.php
Fichier normal
30
app/Http/Requests/Backend/Course/Courses/UpdateRequest.php
Fichier normal
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Backend\Course\Courses;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'courseTitle_en' => 'required|max:255',
|
||||
'categoryId' => 'required|max:3',
|
||||
'instructorId' => 'required|max:3',
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/Backend/Course/Materials/AddNewRequest.php
Fichier normal
30
app/Http/Requests/Backend/Course/Materials/AddNewRequest.php
Fichier normal
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Backend\Course\Materials;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class AddNewRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'materialTitle' => 'required|max:255',
|
||||
'materialType' => 'required|max:255',
|
||||
'courseId' => 'required|max:3',
|
||||
];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/Backend/Course/Materials/UpdateRequest.php
Fichier normal
30
app/Http/Requests/Backend/Course/Materials/UpdateRequest.php
Fichier normal
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Backend\Course\Materials;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'materialTitle' => 'required|max:255',
|
||||
'materialType' => 'required|max:255',
|
||||
'courseId' => 'required|max:3',
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/Http/Requests/Backend/Instructors/AddNewRequest.php
Fichier normal
33
app/Http/Requests/Backend/Instructors/AddNewRequest.php
Fichier normal
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Backend\Instructors;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class AddNewRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'fullName_en' => 'required|max:255',
|
||||
'emailAddress' => 'required|unique:instructors,email',
|
||||
'contactNumber_en' => 'required|unique:instructors,contact_en',
|
||||
'roleId' => 'required|max:3',
|
||||
'password' => 'required',
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Http/Requests/Backend/Instructors/UpdateRequest.php
Fichier normal
32
app/Http/Requests/Backend/Instructors/UpdateRequest.php
Fichier normal
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Backend\Instructors;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(Request $r): array
|
||||
{
|
||||
$id = encryptor('decrypt', $r->uptoken);
|
||||
return [
|
||||
'fullName_en' => 'required|max:255',
|
||||
'emailAddress' => 'required|unique:instructors,email,' . $id,
|
||||
'contactNumber_en' => 'required|unique:instructors,contact_en,' . $id,
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Http/Requests/Backend/Students/AddNewRequest.php
Fichier normal
32
app/Http/Requests/Backend/Students/AddNewRequest.php
Fichier normal
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Backend\Students;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class AddNewRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'fullName_en' => 'required|max:255',
|
||||
'emailAddress' => 'required|unique:instructors,email',
|
||||
'contactNumber_en' => 'required|unique:instructors,contact_en',
|
||||
'roleId' => 'required|max:3',
|
||||
'password' => 'required',
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Http/Requests/Backend/Students/UpdateRequest.php
Fichier normal
32
app/Http/Requests/Backend/Students/UpdateRequest.php
Fichier normal
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Backend\Students;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(Request $r): array
|
||||
{
|
||||
$id = encryptor('decrypt', $r->uptoken);
|
||||
return [
|
||||
'fullName_en' => 'required|max:255',
|
||||
'emailAddress' => 'required|unique:instructors,email,'.$id,
|
||||
'contactNumber_en' => 'required|unique:instructors,contact_en,',$id,
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -22,7 +22,7 @@ public function authorize(): bool
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'userName_en' => 'required|max:255',
|
||||
'userName_en' => 'required|max:255',
|
||||
'roleId' => 'required|max:2',
|
||||
'contactNumber_en' => 'required|unique:users,contact_en',
|
||||
'emailAddress' => 'required|unique:users,email',
|
||||
|
||||
Chargement…
Référencer dans un nouveau ticket
Block a user