|
$deleted = DB::table('users')->delete()
|
bet | 10/13 | Sana | 18.05.2024 | Hajmi | 1,95 Mb. | | #242022 |
Bog'liq YARILKASINOV ASAN ONGARBAY ULI$deleted = DB::table('users')->delete();
$deleted = DB::table('users')->where('votes', '>', 100)->delete();
Models/Student.php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Student extends Model
{
use HasFactory;
protected $guarded = [
'id'
];
}
Controllers/StudentController.php
namespace App\Http\Controllers;
use App\Http\Requests\StoreAdminRequest;
use App\Models\Student;
use App\Http\Requests\StoreStudentRequest;
use App\Http\Requests\UpdateStudentRequest;
use App\Models\Result as ModelsResult;
use App\Models\Subject;
use GuzzleHttp\Psr7\Request;
use Illuminate\Http\Request as HttpRequest;
use LDAP\Result;
use PHPUnit\Framework\MockObject\Builder\Stub;
use function Symfony\Component\String\b;
class StudentController extends Controller
{
public function index()
{
$students = Student::all()->sortBy('fullname');
return view('admin.students', ['students' => $students]);
}
public function store(StoreStudentRequest $request)
{
Student::create($request->validated());
return back();
}
public function result(HttpRequest $request)
{
$request->validate([
'login' => 'required',
'password' => 'required'
]);
$student = Student::where('login', $request->login)->first();
$results = ModelsResult::get();
$subjects = Subject::get();
if(empty($student) OR $student->password != $request->password)
{
return back();
}
if($student->password == $request->password)
{
return view('index', [
'student' => $student,
'results' => $results,
'subjects' => $subjects
]);
}
}
public function edit($id)
{
$student = Student::find($id);
return view('admin.student_edit', ['student' => $student]);
}
public function update(UpdateStudentRequest $request, $id)
{
Student::find($id)->update($request->validated());
return redirect('student');
}
public function destroy($id)
{
Student::destroy($id);
return back();
}
|
| |