Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

academico-sis/academico

338 stars
3 code files
View academico-sis/academico on GitHub

app/Providers/AuthServiceProvider.php

Open in GitHub
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
 
class AuthServiceProvider extends ServiceProvider
{
protected $policies = [
'App\\Model' => 'App\\Policies\\ModelPolicy',
];
//
}

app/Models/Policies/ContactPolicy.php

Open in GitHub
use App\Models\Contact;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
 
class ContactPolicy
{
use HandlesAuthorization;
 
public function update(User $user, Contact $contact)
{
if ($user->can('student.edit')) {
return true;
}
 
if ($user->student) {
return $user->student->id == $contact->student_id;
}
 
return false;
}
}

app/Http/Controllers/ContactController.php

Open in GitHub
use App\Models\Contact;
 
class ContactController extends Controller
{
//
public function edit(Contact $contact)
{
if (! backpack_user()->can('update', $contact)) {
abort(403);
}
 
return view('students.edit-contact', [
'contact' => $contact,
'redirect_url' =>url()->previous(),
]);
}
 
//
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.