Skip to content

Commit

Permalink
feat: Add basic structure for models, controllers,
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] committed Feb 10, 2024
1 parent c4a0476 commit c258ef5
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions app
@@ -0,0 +1,75 @@
// app/Models/Example.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Example extends Model
{
protected $fillable = ['name', 'description'];
}

// app/Http/Controllers/ExampleController.php
<?php

namespace App\Http\Controllers;

use App\Models\Example;
use Illuminate\Http\Request;

class ExampleController extends Controller
{
public function index()
{
$examples = Example::all();
return response()->json($examples);
}

public function store(Request $request)
{
$example = Example::create($request->all());
return response()->json($example, 201);
}
}

// app/Policies/ExamplePolicy.php
<?php

namespace App\Policies;

use App\Models\User;
use App\Models\Example;

class ExamplePolicy
{
public function viewAny(User $user)
{
// Define logic to determine if the user can view any examples
return true;
}

public function view(User $user, Example $example)
{
// Define logic to determine if the user can view a specific example
return true;
}

public function create(User $user)
{
// Define logic to determine if the user can create an example
return true;
}

public function update(User $user, Example $example)
{
// Define logic to determine if the user can update a specific example
return true;
}

public function delete(User $user, Example $example)
{
// Define logic to determine if the user can delete a specific example
return true;
}
}

0 comments on commit c258ef5

Please sign in to comment.