PHP code example of maxfactor / support

1. Go to this page and download the library: Download maxfactor/support 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/ */

    

maxfactor / support example snippets


use Maxfactor\Support\Model\Traits\HasActiveState;

$table->active();

public function viewInactive($user, $model)
{
    if (config('maxfactor-support.canViewInactive')) {
        return true;
    }

    // Your logic... (Gate::allows() etc)

    return false;
}

use Maxfactor\Support\Model\Traits\CanBeFeatured;

$table->featured();

use Spatie\EloquentSortable\Sortable;
use Maxfactor\Support\Model\Traits\HasSortOrder;

class Category extends Model implements Sortable
{
    use HasSortOrder;
    ...
}

$table->sortable();

$results = Model::sorted()->get();

return view('my.view')->with('page', $model)

$table->meta();

@render('maxfactor:webpage::browserTitle', ['title' => Arr::get($page ?? [], 'browserTitle', config('app.name'))])

@render('maxfactor:webpage::metaDescription', ['description' => Arr::get($page ?? [], 'metaDescription')])

// Define our additional fields in the resource.
protected function additionalMetaFields()
{
    return [
        Text::make('Example Meta Content'),
    ];
}

// Inside the resources fields() function we can pass in our additional fields as a parameter.
MetaAttributes::make($this->additionalMetaFields()),

public function seeds()
{
    return array_merge(parent::seeds(), [[
        'name' => __('Branch finder'),
        'url' => route('branch.index'),
    ], [
        'name' => $this->navTitle,
        'url' => route('branch.show', $this),
    ]]);
}

// Branch Controller
$branch->seed($name = __('Audiologists'), $url = route('branch.audiologists', $branch), $status = null);

// config/maxfactor-support.php
'homeBreadcrumb' => 'Home',

public function baseCanonical()
{
    return route('branch.show', $this);
}

$branch->canonical($url);

@

// Assuming the current url is https://example.com/journal?page=2&tag=news

Maxfactor::urlWithQuerystring('https://example.com/blog', $allowedParameters = 'page=[^1]');

// returns https://example.com/blog?page=2


namespace App\Console;

use Maxfactor\Support\Webpage\Commands\MakeSitemap;

class Sitemap extends MakeSitemap
{
    /**
     * Populate the sitemap. This method should be overloaded to add content.
     *
     * @param Sitemap $sitemap
     * @return void
     */
    public function populate($sitemap)
    {
        // $sitemap->add('/url');
    }
}

'enforceDomainsStatusCodes' => [
    \Symfony\Component\HttpFoundation\Response::HTTP_OK,
    \Symfony\Component\HttpFoundation\Response::HTTP_MOVED_PERMANENTLY,
    \Symfony\Component\HttpFoundation\Response::HTTP_TEMPORARY_REDIRECT,
    \Symfony\Component\HttpFoundation\Response::HTTP_PERMANENTLY_REDIRECT,
],

protected $routeMiddleware = [
    ...
    'auth.environment' => \Maxfactor\Support\Webpage\Middleware\EnvironmentAuth::class,
];

    // config/auth.php

    ...
    /*
    |--------------------------------------------------------------------------
    | Environments
    |--------------------------------------------------------------------------
    |
    | Determine which environments should be password protected.
    |
    */

    'environments' => [
        'staging',
    ],

// App\Page.php

class Page extends Model implements Maxfactor\Support\Webpage\Contracts\SearchResult
{
    use Maxfactor\Support\Webpage\Traits\IsSearchResult;

    // Implement the public function getResultSummaryAttribute()
    {
        return $this->summary;
    }

    public function getResultUrlAttribute()
    {
        return $this->mapped_url;
    }

    public function getResultImageAttribute()
    {
        return $this->image;
    }
}

$results = Search::for($query)->in([
    Article::published(), // Builder
    app(Page::class), // Model
])->get();

$results = Search::for($query)->in([
    Article::published(), // Builder
    app(Page::class), // Model
])->paginate(2);