Skip to content

Commit

Permalink
profil kampus
Browse files Browse the repository at this point in the history
  • Loading branch information
iqbalroni committed Dec 3, 2024
1 parent 546c917 commit 7a9369b
Show file tree
Hide file tree
Showing 16 changed files with 733 additions and 540 deletions.
74 changes: 74 additions & 0 deletions app/Http/Controllers/ProfilKampusController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

namespace App\Http\Controllers;

use App\Models\ProfilKampus;
use Illuminate\Http\Request;
use Inertia\Inertia;

class ProfilKampusController extends Controller
{
/**
* Display a listing of the resource.
*/
private $data = [
'baseUrl'=>'/profilKampus',
'title'=>'Profil Kampus'
];

public function index()
{
$this->data['data'] = ProfilKampus::first();
return Inertia('ProfilKampus/Index',$this->data);
}

/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
$request->validate([
'nama_kampus'=>'required',
'singkatan'=>'required',
'email'=>'email|required',
'logo'=>'mimes:png',
'alamat'=>'required'
]);

ProfilKampus::where('id_kampus','1')->update($request->all());

return redirect()->route('profilkampus')->with('success','berhasil memperbarui profil kampus');
}

/**
* Display the specified resource.
*/
public function show(ProfilKampus $profilKampus)
{
//
}

/**
* Show the form for editing the specified resource.
*/
public function edit(ProfilKampus $profilKampus)
{
//
}

/**
* Update the specified resource in storage.
*/
public function update(Request $request, ProfilKampus $profilKampus)
{
//
}

/**
* Remove the specified resource from storage.
*/
public function destroy(ProfilKampus $profilKampus)
{
//
}
}
3 changes: 3 additions & 0 deletions app/Http/Middleware/HandleInertiaRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Middleware;

use App\Models\ProfilKampus;
use App\Models\Semester;
use Illuminate\Http\Request;
use Inertia\Middleware;
Expand Down Expand Up @@ -53,6 +54,8 @@ public function share(Request $request): array
'semester'=>[
'smt_aktif' => Semester::where('status_aktif',true)->first()->nama_semester,
],

'profil'=> ProfilKampus::where('id_kampus',1)->first(),
]);
}
}
12 changes: 12 additions & 0 deletions app/Models/ProfilKampus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ProfilKampus extends Model
{
use HasFactory;
protected $primaryKey = 'id_kampus';
}
Loading

0 comments on commit 7a9369b

Please sign in to comment.