PHP code example of campelo / laravel-make-full

1. Go to this page and download the library: Download campelo/laravel-make-full library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

campelo / laravel-make-full example snippets


public function search(array $params = []): LengthAwarePaginator
{
    $query = Post::query();

    // Search filter
    if (!empty($params['search'])) {
        $search = $params['search'];
        $query->where(function ($q) use ($search) {
            $q->where('title', 'like', "%{$search}%");
            $q->orWhere('content', 'like', "%{$search}%");
        });
    }

    // Sorting
    $sortField = $params['sort'] ?? 'created_at';
    $sortOrder = $params['order'] ?? 'desc';
    $query->orderBy($sortField, $sortOrder);

    // Pagination
    $limit = $params['limit'] ?? 15;

    return $query->paginate($limit);
}

public function index(Request $request): AnonymousResourceCollection
{
    $result = $this->service->search($request->all());

    return PostResource::collection($result);
}

public function rules(): array
{
    return [
        'title' => 'sometimes|      'string|max:255',
            Rule::unique('posts', 'slug')->ignore($this->post?->id),
        ],
        'content' => 'sometimes|

// config/make-full.php

return [
    // Namespaces
    'namespaces' => [
        'model' => 'App\\Models',
        'controller' => 'App\\Http\\Controllers',
        'service' => 'App\\Services',
        'repository' => 'App\\Repositories',
        // ...
    ],

    // Use repository pattern (Controller -> Service -> Repository)
    'use_repository' => true,

    // Default pagination
    'default_pagination' => 15,

    // Auto-add routes to api.php
    'add_routes' => true,
];
bash
php artisan vendor:publish --tag=make-full-stubs