PHP code example of mawelous / yamop-laravel

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

    

mawelous / yamop-laravel example snippets


    'mongo' => array(
        'host'     => 'host',
        'port'     => 37847,
        'database' => 'db',
        'user'     => 'user',
        'password' => 'pass'
    ),

    ...
    'Illuminate\View\ViewServiceProvider',
    'Illuminate\Workbench\WorkbenchServiceProvider',
    ...
    'Mawelous\YamopLaravel\YamopLaravelServiceProvider',

    ...
    'Validator'       => 'Illuminate\Support\Facades\Validator',
    'View'            => 'Illuminate\Support\Facades\View',
    ...
    'Mapper'          => 'Mawelous\YamopLaravel\Mapper',
    'Model'           => 'Mawelous\YamopLaravel\Model',

    class Article extends Model
    {
        protected static $_collectionName = 'articles';
    }

    User::getMapper()
        ->find( 'status' => [ '$ne' => User::STATUS_DELETED ] ) )
        ->sort( [ $field => $direction ] )
        ->getPaginator( $perPage );

    //or
    User::getMapper()
        ->find()
        ->getPaginator( $perPage, $currentPage, 'commentsPage' );

    class User extends Mawelous\YamopLaravel\User
    {
        protected static $_collectionName = 'users';    
    }

    ...
    'driver' => 'yamop',
    ...

    class AuthController extends BaseController {
    
        public function getLogin()
        {
            return View::make( 'auth.login' );
        }
        
        public function postLogin()
        {
            if( Auth::attempt( [ 'nickname' => Input::get( 'nickname' ), 'password' => input::get( 'password' ) ] ) )
            {
                return Redirect::intended( 'dashboard' );
            } else {
                return Redirect::to( '/login' )->with( 'login_failed', true );
            }       
        }
    }