PHP code example of mcesar / laravel-survey

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

    

mcesar / laravel-survey example snippets


// Get all question that a user has
Question::answered(false)->get()

'providers' => [
    // ...
    MCesar\Survey\SurveyServiceProvider::class,
];

return [

    'models' => [

        /*
         * We need to know which Eloquent model should be used to retrieve your categories.
         * Of course, it is often just the "Category" model but you may use whatever you like.
         *
         * The model you want to use as a Category model needs to implement the
         * `MCesar\Survey\Contracts\Category` contract.
         */

        'category' => MCesar\Survey\Models\Category::class,

        /*
         * We need to know which Eloquent model should be used to retrieve your questions.
         * Of course, it is often just the "Question" model but you may use whatever you like.
         *
         * The model you want to use as a Question model needs to implement the
         * `MCesar\Survey\Question\Category` contract.
         */

        'question' => MCesar\Survey\Models\Question::class,

        /*
         * We need to know which Eloquent model should be used to retrieve your answers.
         * Of course, it is often just the "Answer" model but you may use whatever you like.
         *
         * The model you want to use as a Answer model needs to implement the
         * `MCesar\Survey\Question\Answer` contract.
         */

        'answer' => MCesar\Survey\Models\Answer::class,

        /*
         * We need to know which Eloquent model should be used to assign the answers to.
         * Of course, it is often just the "User" model but you may use whatever you like.
         */

        'user' => App\User::class,

    ],
];

$app->configure('survey');
$app->register(MCesar\Survey\SurveyServiceProvider::class);
bash
php artisan vendor:publish --provider="MCesar\Survey\SurveyServiceProvider" --tag="migrations"
bash
php artisan migrate
bash
php artisan vendor:publish --provider="MCesar\Survey\SurveyServiceProvider" --tag="config"
bash
cp vendor/mcesar/laravel-survey/config/permission.php config/survey.php
cp vendor/mcesar/laravel-survey/database/migrations/create_survey_tables.php.stub database/migrations/2018_01_01_000000_create_survey_tables.php
bash
php artisan migrate
bash
php artisan vendor:publish --provider="MCesar\Survey\SurveyServiceProvider" --tag="config"