├── .deployment ├── .env.sample.php ├── .env.testing.sample.php ├── .gitattributes ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── app ├── commands │ └── .gitkeep ├── config │ ├── app.php │ ├── auth.php │ ├── cache.php │ ├── compile.php │ ├── database.php │ ├── init │ │ └── database.php │ ├── int │ │ └── database.php │ ├── live │ │ └── database.php │ ├── local │ │ ├── app.php │ │ └── database.php │ ├── mail.php │ ├── packages │ │ └── .gitkeep │ ├── queue.php │ ├── remote.php │ ├── services.php │ ├── session.php │ ├── stage │ │ ├── app.php │ │ └── database.php │ ├── test │ │ └── database.php │ ├── testing │ │ ├── cache.php │ │ ├── database.php │ │ └── session.php │ ├── view.php │ └── workbench.php ├── controllers │ ├── .gitkeep │ ├── ApiController.php │ ├── BaseController.php │ ├── ContactController.php │ ├── FavoriteController.php │ ├── HomeController.php │ ├── RemindersController.php │ └── UserController.php ├── database │ ├── .gitignore │ ├── migrations │ │ ├── .gitkeep │ │ ├── 2014_10_13_184737_create_users_table.php │ │ ├── 2014_10_14_124202_create_password_reminders_table.php │ │ ├── 2014_10_31_063959_create_favorites_table.php │ │ ├── 2014_11_19_151007_create_user_profile_table.php │ │ ├── 2014_11_20_070730_create_contact_groups_table.php │ │ └── 2014_11_20_070843_create_contacts_table.php │ └── seeds │ │ ├── .gitkeep │ │ ├── DatabaseSeeder.php │ │ └── UsersTableSeeder.php ├── filters.php ├── lang │ └── en │ │ ├── pagination.php │ │ ├── reminders.php │ │ └── validation.php ├── models │ ├── Contact.php │ ├── Favorite.php │ ├── Group.php │ ├── Profile.php │ └── User.php ├── molio │ ├── ApiDataMapper │ │ ├── ContactDataMapper.php │ │ ├── DataMapper.php │ │ ├── FavoriteDataMapper.php │ │ ├── GroupDataMapper.php │ │ └── UserDataMapper.php │ ├── SiteHelpers │ │ └── commonDebugHelpers.php │ └── Validation │ │ ├── ContactForm.php │ │ ├── ContactGroupForm.php │ │ ├── FavoriteForm.php │ │ ├── FavoriteUpdateForm.php │ │ ├── ImageUploadForm.php │ │ ├── LoginForm.php │ │ ├── PasswordForm.php │ │ ├── RegistrationForm.php │ │ └── UpdateForm.php ├── routes.php ├── start │ ├── artisan.php │ ├── global.php │ └── local.php ├── storage │ ├── .gitignore │ ├── cache │ │ └── .gitignore │ ├── logs │ │ └── .gitignore │ ├── meta │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ └── views │ │ └── .gitignore ├── tests │ ├── ApiTester.php │ ├── ContactTest.php │ ├── FavoriteItemTest.php │ ├── TestCase.php │ └── UserTest.php └── views │ ├── emails │ └── auth │ │ └── reminder.blade.php │ └── hello.php ├── artisan ├── bootstrap ├── autoload.php ├── paths.php └── start.php ├── build.xml ├── build ├── phpcs.xml ├── phpdox.xml └── phpmd.xml ├── composer.json ├── config.xml ├── deploy.sh ├── deploy.sh~ ├── phpunit.xml ├── phpunit.xml.dist ├── public ├── .htaccess ├── favicon.ico ├── img │ └── usr_sreej32h.jpg ├── index.php ├── packages │ └── .gitkeep └── robots.txt ├── server.php └── web.config /.deployment: -------------------------------------------------------------------------------- 1 | [config] 2 | command = bash deploy.sh -------------------------------------------------------------------------------- /.env.sample.php: -------------------------------------------------------------------------------- 1 | "localhost", 5 | "DB_AUTH_USERNAME" => "", 6 | "DB_AUTH_PASSWORD" => "", 7 | "DB_NAME" => "userapi", 8 | "MAIL_SMTP_HOST"=>'', 9 | 'MAIL_SMTP_PORT'=> 587, 10 | 'MAIL_FROM_ADDRESS'=>'', 11 | 'MAIL_FROM_NAME'=>'', 12 | 'MAIL_USERNAME'=>'', 13 | 'MAIL_PASSWORD'=>'', 14 | 15 | ]; 16 | -------------------------------------------------------------------------------- /.env.testing.sample.php: -------------------------------------------------------------------------------- 1 | "localhost", 5 | "DB_AUTH_USERNAME" => "", 6 | "DB_AUTH_PASSWORD" => "", 7 | "DB_NAME" => "", 8 | "MAIL_SMTP_HOST"=>'smtp.gmail.com', 9 | 'MAIL_SMTP_PORT'=> 587, 10 | 'MAIL_FROM_ADDRESS'=>'', 11 | 'MAIL_FROM_NAME'=>'', 12 | 'MAIL_USERNAME'=>'', 13 | 'MAIL_PASSWORD'=>'', 14 | 15 | ]; 16 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /bootstrap/compiled.php 2 | /vendor 3 | composer.phar 4 | composer.lock 5 | 6 | .DS_Store 7 | Thumbs.db 8 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guidelines 2 | 3 | Please submit all issues and pull requests to the [laravel/framework](http://github.com/laravel/framework) repository! 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 fasilkk 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Laravel PHP Framework 2 | 3 | ## URL 4 | 5 | | URI | Action | 6 | | ---------------------------------------------------------------------------:|---------------------------------:| 7 | | POST api/user/register | UserController@register | 8 | | POST api/user/login | UserController@login | 9 | | GET api/user/logout | UserController@logout | 10 | | POST api/user/password/remind | RemindersController@postRemind | 11 | | GET|HEAD api/user/password/reset | RemindersController@getReset | 12 | | POST api/user/password/reset | RemindersController@postReset | 13 | | GET|HEAD api/user/password/staus-code | RemindersController@getStausCode | 14 | | GET api/user/status | UserController@status | 15 | | GET api/user/{user} | UserController@show | 16 | | PUT api/user/{user} | UserController@update | 17 | | PATCH api/user/{user} | UserController@update | 18 | | DELETE api/user/{user} | UserController@destroy | 19 | | | 20 | | POST api/user/password/update | UserController@postUserPasswordUpdate | | 21 | | POST api/user/profile/image | UserController@postUserImage | 22 | | POST api/favorite | FavoriteController@store | 23 | | GET api/favorite/count | FavoriteController@count | 24 | | GET|HEAD api/favorites | FavoriteController@index | 25 | | PUT api/favorites/{favorite} | FavoriteController@update | 26 | | PATCH api/favorites/{favorite} | FavoriteController@update | 27 | | DELETE api/favorites/{favorite} | FavoriteController@destroy | 28 | 29 | 30 | 31 | ## Register fields 32 | 33 | > 'username' : 'required|unique:users', 34 | 35 | > 'email' : 'required|unique:users|email', 36 | 37 | > 'password' : 'required', 38 | 39 | > 'fname' : 'required|min:3|max:30', 40 | 41 | > 'lname' : 'required|max:20', 42 | 43 | > 'address' : 'required|min:10', 44 | 45 | 46 | 47 | ## Login 48 | 49 | > 'username' : 'required', 50 | 51 | > 'password' : 'required' 52 | 53 | 54 | 55 | #Post image 56 | 57 | 'image': 'required' 58 | 59 | 60 | #password 61 | 62 | >'password': 'required|min:5' 63 | 64 | >'passwordmatch': 'required|same:password|min:5' 65 | 66 | 67 | #Post favorites: 68 | 69 | 'name': 'required|min:2' 70 | 71 | 'address': 'required|min:5' 72 | 73 | 'lat' : 'required' 74 | 75 | 'lng' : 'required' 76 | 77 | 78 | #Update favorites 79 | 80 | 81 | 'name' : 'required|min:2' 82 | 83 | Note: Laravel's PATCH and PUT request are just cheating, by adding a hidden field. Ex: . Laravel will create such a field automatically in all laravel's HTML forms. In postman you should point that the data you send is 'x-www-url-formurlencoded' for PATCH. Alternatively your can sent a POST request with an hidden field named _method and value PATCH. 84 | -------------------------------------------------------------------------------- /app/commands/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fasilkk/SampleRestAPI/9080ffddc9414bb0cdc673918f79ea6ac0a4d70b/app/commands/.gitkeep -------------------------------------------------------------------------------- /app/config/app.php: -------------------------------------------------------------------------------- 1 | false, 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Application URL 21 | |-------------------------------------------------------------------------- 22 | | 23 | | This URL is used by the console to properly generate URLs when using 24 | | the Artisan command line tool. You should set this to the root of 25 | | your application so that it is used when running Artisan tasks. 26 | | 27 | */ 28 | 29 | 'url' => 'http://localhost', 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Application Timezone 34 | |-------------------------------------------------------------------------- 35 | | 36 | | Here you may specify the default timezone for your application, which 37 | | will be used by the PHP date and date-time functions. We have gone 38 | | ahead and set this to a sensible default for you out of the box. 39 | | 40 | */ 41 | 42 | 'timezone' => 'UTC', 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Application Locale Configuration 47 | |-------------------------------------------------------------------------- 48 | | 49 | | The application locale determines the default locale that will be used 50 | | by the translation service provider. You are free to set this value 51 | | to any of the locales which will be supported by the application. 52 | | 53 | */ 54 | 55 | 'locale' => 'en', 56 | 57 | /* 58 | |-------------------------------------------------------------------------- 59 | | Application Fallback Locale 60 | |-------------------------------------------------------------------------- 61 | | 62 | | The fallback locale determines the locale to use when the current one 63 | | is not available. You may change the value to correspond to any of 64 | | the language folders that are provided through your application. 65 | | 66 | */ 67 | 68 | 'fallback_locale' => 'en', 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Encryption Key 73 | |-------------------------------------------------------------------------- 74 | | 75 | | This key is used by the Illuminate encrypter service and should be set 76 | | to a random, 32 character string, otherwise these encrypted strings 77 | | will not be safe. Please do this before deploying an application! 78 | | 79 | */ 80 | 81 | 'key' => 'YourSecretKey!!!', 82 | 83 | 'cipher' => MCRYPT_RIJNDAEL_128, 84 | 85 | /* 86 | |-------------------------------------------------------------------------- 87 | | Autoloaded Service Providers 88 | |-------------------------------------------------------------------------- 89 | | 90 | | The service providers listed here will be automatically loaded on the 91 | | request to your application. Feel free to add your own services to 92 | | this array to grant expanded functionality to your applications. 93 | | 94 | */ 95 | 96 | 'providers' => [ 97 | 98 | 'Illuminate\Foundation\Providers\ArtisanServiceProvider', 99 | 'Illuminate\Auth\AuthServiceProvider', 100 | 'Illuminate\Cache\CacheServiceProvider', 101 | 'Illuminate\Session\CommandsServiceProvider', 102 | 'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', 103 | 'Illuminate\Routing\ControllerServiceProvider', 104 | 'Illuminate\Cookie\CookieServiceProvider', 105 | 'Illuminate\Database\DatabaseServiceProvider', 106 | 'Illuminate\Encryption\EncryptionServiceProvider', 107 | 'Illuminate\Filesystem\FilesystemServiceProvider', 108 | 'Illuminate\Hashing\HashServiceProvider', 109 | 'Illuminate\Html\HtmlServiceProvider', 110 | 'Illuminate\Log\LogServiceProvider', 111 | 'Illuminate\Mail\MailServiceProvider', 112 | 'Illuminate\Database\MigrationServiceProvider', 113 | 'Illuminate\Pagination\PaginationServiceProvider', 114 | 'Illuminate\Queue\QueueServiceProvider', 115 | 'Illuminate\Redis\RedisServiceProvider', 116 | 'Illuminate\Remote\RemoteServiceProvider', 117 | 'Illuminate\Auth\Reminders\ReminderServiceProvider', 118 | 'Illuminate\Database\SeedServiceProvider', 119 | 'Illuminate\Session\SessionServiceProvider', 120 | 'Illuminate\Translation\TranslationServiceProvider', 121 | 'Illuminate\Validation\ValidationServiceProvider', 122 | 'Illuminate\View\ViewServiceProvider', 123 | 'Illuminate\Workbench\WorkbenchServiceProvider', 124 | 'Way\Generators\GeneratorsServiceProvider', 125 | 'Laracasts\Validation\ValidationServiceProvider', 126 | 127 | ], 128 | 129 | /* 130 | |-------------------------------------------------------------------------- 131 | | Service Provider Manifest 132 | |-------------------------------------------------------------------------- 133 | | 134 | | The service provider manifest is used by Laravel to lazy load service 135 | | providers which are not needed for each request, as well to keep a 136 | | list of all of the services. Here, you may set its storage spot. 137 | | 138 | */ 139 | 140 | 'manifest' => storage_path().'/meta', 141 | 142 | /* 143 | |-------------------------------------------------------------------------- 144 | | Class Aliases 145 | |-------------------------------------------------------------------------- 146 | | 147 | | This array of class aliases will be registered when this application 148 | | is started. However, feel free to register as many as you wish as 149 | | the aliases are "lazy" loaded so they don't hinder performance. 150 | | 151 | */ 152 | 153 | 'aliases' => [ 154 | 155 | 'App' => 'Illuminate\Support\Facades\App', 156 | 'Artisan' => 'Illuminate\Support\Facades\Artisan', 157 | 'Auth' => 'Illuminate\Support\Facades\Auth', 158 | 'Blade' => 'Illuminate\Support\Facades\Blade', 159 | 'Cache' => 'Illuminate\Support\Facades\Cache', 160 | 'ClassLoader' => 'Illuminate\Support\ClassLoader', 161 | 'Config' => 'Illuminate\Support\Facades\Config', 162 | 'Controller' => 'Illuminate\Routing\Controller', 163 | 'Cookie' => 'Illuminate\Support\Facades\Cookie', 164 | 'Crypt' => 'Illuminate\Support\Facades\Crypt', 165 | 'DB' => 'Illuminate\Support\Facades\DB', 166 | 'Eloquent' => 'Illuminate\Database\Eloquent\Model', 167 | 'Event' => 'Illuminate\Support\Facades\Event', 168 | 'File' => 'Illuminate\Support\Facades\File', 169 | 'Form' => 'Illuminate\Support\Facades\Form', 170 | 'Hash' => 'Illuminate\Support\Facades\Hash', 171 | 'HTML' => 'Illuminate\Support\Facades\HTML', 172 | 'Input' => 'Illuminate\Support\Facades\Input', 173 | 'Lang' => 'Illuminate\Support\Facades\Lang', 174 | 'Log' => 'Illuminate\Support\Facades\Log', 175 | 'Mail' => 'Illuminate\Support\Facades\Mail', 176 | 'Paginator' => 'Illuminate\Support\Facades\Paginator', 177 | 'Password' => 'Illuminate\Support\Facades\Password', 178 | 'Queue' => 'Illuminate\Support\Facades\Queue', 179 | 'Redirect' => 'Illuminate\Support\Facades\Redirect', 180 | 'Redis' => 'Illuminate\Support\Facades\Redis', 181 | 'Request' => 'Illuminate\Support\Facades\Request', 182 | 'Response' => 'Illuminate\Support\Facades\Response', 183 | 'Route' => 'Illuminate\Support\Facades\Route', 184 | 'Schema' => 'Illuminate\Support\Facades\Schema', 185 | 'Seeder' => 'Illuminate\Database\Seeder', 186 | 'Session' => 'Illuminate\Support\Facades\Session', 187 | 'SoftDeletingTrait' => 'Illuminate\Database\Eloquent\SoftDeletingTrait', 188 | 'SSH' => 'Illuminate\Support\Facades\SSH', 189 | 'Str' => 'Illuminate\Support\Str', 190 | 'URL' => 'Illuminate\Support\Facades\URL', 191 | 'Validator' => 'Illuminate\Support\Facades\Validator', 192 | 'View' => 'Illuminate\Support\Facades\View', 193 | 194 | ], 195 | 196 | ]; 197 | -------------------------------------------------------------------------------- /app/config/auth.php: -------------------------------------------------------------------------------- 1 | 'eloquent', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Authentication Model 23 | |-------------------------------------------------------------------------- 24 | | 25 | | When using the "Eloquent" authentication driver, we need to know which 26 | | Eloquent model should be used to retrieve your users. Of course, it 27 | | is often just the "User" model but you may use whatever you like. 28 | | 29 | */ 30 | 31 | 'model' => 'User', 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | Authentication Table 36 | |-------------------------------------------------------------------------- 37 | | 38 | | When using the "Database" authentication driver, we need to know which 39 | | table should be used to retrieve your users. We have chosen a basic 40 | | default value but you may easily change it to any table you like. 41 | | 42 | */ 43 | 44 | 'table' => 'users', 45 | 46 | /* 47 | |-------------------------------------------------------------------------- 48 | | Password Reminder Settings 49 | |-------------------------------------------------------------------------- 50 | | 51 | | Here you may set the settings for password reminders, including a view 52 | | that should be used as your password reminder e-mail. You will also 53 | | be able to set the name of the table that holds the reset tokens. 54 | | 55 | | The "expire" time is the number of minutes that the reminder should be 56 | | considered valid. This security feature keeps tokens short-lived so 57 | | they have less time to be guessed. You may change this as needed. 58 | | 59 | */ 60 | 61 | 'reminder' => [ 62 | 63 | 'email' => 'emails.auth.reminder', 64 | 65 | 'table' => 'password_reminders', 66 | 67 | 'expire' => 60, 68 | 69 | ], 70 | 71 | ]; 72 | -------------------------------------------------------------------------------- /app/config/cache.php: -------------------------------------------------------------------------------- 1 | 'file', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | File Cache Location 23 | |-------------------------------------------------------------------------- 24 | | 25 | | When using the "file" cache driver, we need a location where the cache 26 | | files may be stored. A sensible default has been specified, but you 27 | | are free to change it to any other place on disk that you desire. 28 | | 29 | */ 30 | 31 | 'path' => storage_path().'/cache', 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | Database Cache Connection 36 | |-------------------------------------------------------------------------- 37 | | 38 | | When using the "database" cache driver you may specify the connection 39 | | that should be used to store the cached items. When this option is 40 | | null the default database connection will be utilized for cache. 41 | | 42 | */ 43 | 44 | 'connection' => null, 45 | 46 | /* 47 | |-------------------------------------------------------------------------- 48 | | Database Cache Table 49 | |-------------------------------------------------------------------------- 50 | | 51 | | When using the "database" cache driver we need to know the table that 52 | | should be used to store the cached items. A default table name has 53 | | been provided but you're free to change it however you deem fit. 54 | | 55 | */ 56 | 57 | 'table' => 'cache', 58 | 59 | /* 60 | |-------------------------------------------------------------------------- 61 | | Memcached Servers 62 | |-------------------------------------------------------------------------- 63 | | 64 | | Now you may specify an array of your Memcached servers that should be 65 | | used when utilizing the Memcached cache driver. All of the servers 66 | | should contain a value for "host", "port", and "weight" options. 67 | | 68 | */ 69 | 70 | 'memcached' => [ 71 | 72 | ['host' => '127.0.0.1', 'port' => 11211, 'weight' => 100], 73 | 74 | ], 75 | 76 | /* 77 | |-------------------------------------------------------------------------- 78 | | Cache Key Prefix 79 | |-------------------------------------------------------------------------- 80 | | 81 | | When utilizing a RAM based store such as APC or Memcached, there might 82 | | be other applications utilizing the same cache. So, we'll specify a 83 | | value to get prefixed to all our keys so we can avoid collisions. 84 | | 85 | */ 86 | 87 | 'prefix' => 'laravel', 88 | 89 | ]; 90 | -------------------------------------------------------------------------------- /app/config/compile.php: -------------------------------------------------------------------------------- 1 | PDO::FETCH_CLASS, 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Default Database Connection Name 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may specify which of the database connections below you wish 24 | | to use as your default connection for all database work. Of course 25 | | you may use many connections at once using the Database library. 26 | | 27 | */ 28 | 29 | 'default' => 'mysql', 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Database Connections 34 | |-------------------------------------------------------------------------- 35 | | 36 | | Here are each of the database connections setup for your application. 37 | | Of course, examples of configuring each database platform that is 38 | | supported by Laravel is shown below to make development simple. 39 | | 40 | | 41 | | All database work in Laravel is done through the PHP PDO facilities 42 | | so make sure you have the driver for your particular database of 43 | | choice installed on your machine before you begin development. 44 | | 45 | */ 46 | 47 | 'connections' => [ 48 | 49 | 'sqlite' => [ 50 | 'driver' => 'sqlite', 51 | 'database' => __DIR__.'/../database/production.sqlite', 52 | 'prefix' => '', 53 | ], 54 | 55 | 'mysql' => [ 56 | 'driver' => 'mysql', 57 | 'host' => getenv('DB_HOST'), 58 | 'database' => getenv('DB_NAME'), 59 | 'username' => getenv('DB_AUTH_USERNAME'), 60 | 'password' => getenv('DB_AUTH_PASSWORD'), 61 | 'charset' => 'utf8', 62 | 'collation' => 'utf8_unicode_ci', 63 | 'prefix' => '', 64 | ], 65 | 66 | 'pgsql' => [ 67 | 'driver' => 'pgsql', 68 | 'host' => 'localhost', 69 | 'database' => 'forge', 70 | 'username' => 'forge', 71 | 'password' => '', 72 | 'charset' => 'utf8', 73 | 'prefix' => '', 74 | 'schema' => 'public', 75 | ], 76 | 77 | 'sqlsrv' => [ 78 | 'driver' => 'sqlsrv', 79 | 'host' => 'localhost', 80 | 'database' => 'database', 81 | 'username' => 'root', 82 | 'password' => '', 83 | 'prefix' => '', 84 | ], 85 | 86 | ], 87 | 88 | /* 89 | |-------------------------------------------------------------------------- 90 | | Migration Repository Table 91 | |-------------------------------------------------------------------------- 92 | | 93 | | This table keeps track of all the migrations that have already run for 94 | | your application. Using this information, we can determine which of 95 | | the migrations on disk haven't actually been run in the database. 96 | | 97 | */ 98 | 99 | 'migrations' => 'migrations', 100 | 101 | /* 102 | |-------------------------------------------------------------------------- 103 | | Redis Databases 104 | |-------------------------------------------------------------------------- 105 | | 106 | | Redis is an open source, fast, and advanced key-value store that also 107 | | provides a richer set of commands than a typical key-value systems 108 | | such as APC or Memcached. Laravel makes it easy to dig right in. 109 | | 110 | */ 111 | 112 | 'redis' => [ 113 | 114 | 'cluster' => false, 115 | 116 | 'default' => [ 117 | 'host' => '127.0.0.1', 118 | 'port' => 6379, 119 | 'database' => 0, 120 | ], 121 | 122 | ], 123 | 124 | ]; 125 | -------------------------------------------------------------------------------- /app/config/init/database.php: -------------------------------------------------------------------------------- 1 | [ 20 | 'mysql' => [ 21 | 'driver' => 'mysql', 22 | 'host' => 'localhost', 23 | 'database' => 'api-i01', 24 | 'username' => 'ciApi2014', 25 | 'password' => 'ciApi2014!', 26 | 'charset' => 'utf8', 27 | 'collation' => 'utf8_unicode_ci', 28 | 'prefix' => '', 29 | ], 30 | ], 31 | ]; 32 | -------------------------------------------------------------------------------- /app/config/int/database.php: -------------------------------------------------------------------------------- 1 | [ 22 | 23 | 'mysql' => [ 24 | 'driver' => 'mysql', 25 | 'host' => 'localhost', 26 | 'database' => 'api-i01', 27 | 'username' => 'ciApi2014', 28 | 'password' => 'ciApi2014!', 29 | 'charset' => 'utf8', 30 | 'collation' => 'utf8_unicode_ci', 31 | 'prefix' => '', 32 | ], 33 | 34 | ], 35 | 36 | ]; 37 | -------------------------------------------------------------------------------- /app/config/live/database.php: -------------------------------------------------------------------------------- 1 | [ 22 | 23 | 'mysql' => [ 24 | 'driver' => 'mysql', 25 | 'host' => 'localhost', 26 | 'database' => 'api-l01', 27 | 'username' => 'ciApi2014', 28 | 'password' => 'ciApi2014!', 29 | 'charset' => 'utf8', 30 | 'collation' => 'utf8_unicode_ci', 31 | 'prefix' => '', 32 | ], 33 | 34 | ], 35 | 36 | ]; 37 | -------------------------------------------------------------------------------- /app/config/local/app.php: -------------------------------------------------------------------------------- 1 | true, 17 | 18 | 'providers' => [ 19 | 20 | 'Illuminate\Foundation\Providers\ArtisanServiceProvider', 21 | 'Illuminate\Auth\AuthServiceProvider', 22 | 'Illuminate\Cache\CacheServiceProvider', 23 | 'Illuminate\Session\CommandsServiceProvider', 24 | 'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', 25 | 'Illuminate\Routing\ControllerServiceProvider', 26 | 'Illuminate\Cookie\CookieServiceProvider', 27 | 'Illuminate\Database\DatabaseServiceProvider', 28 | 'Illuminate\Encryption\EncryptionServiceProvider', 29 | 'Illuminate\Filesystem\FilesystemServiceProvider', 30 | 'Illuminate\Hashing\HashServiceProvider', 31 | 'Illuminate\Html\HtmlServiceProvider', 32 | 'Illuminate\Log\LogServiceProvider', 33 | 'Illuminate\Mail\MailServiceProvider', 34 | 'Illuminate\Database\MigrationServiceProvider', 35 | 'Illuminate\Pagination\PaginationServiceProvider', 36 | 'Illuminate\Queue\QueueServiceProvider', 37 | 'Illuminate\Redis\RedisServiceProvider', 38 | 'Illuminate\Remote\RemoteServiceProvider', 39 | 'Illuminate\Auth\Reminders\ReminderServiceProvider', 40 | 'Illuminate\Database\SeedServiceProvider', 41 | 'Illuminate\Session\SessionServiceProvider', 42 | 'Illuminate\Translation\TranslationServiceProvider', 43 | 'Illuminate\Validation\ValidationServiceProvider', 44 | 'Illuminate\View\ViewServiceProvider', 45 | 'Illuminate\Workbench\WorkbenchServiceProvider', 46 | 'Way\Generators\GeneratorsServiceProvider', 47 | 'Laracasts\Validation\ValidationServiceProvider', 48 | 49 | ], 50 | 51 | ]; 52 | -------------------------------------------------------------------------------- /app/config/local/database.php: -------------------------------------------------------------------------------- 1 | [ 22 | 23 | 'mysql' => [ 24 | 'driver' => 'mysql', 25 | 'host' => getenv('DB_HOST'), 26 | 'database' => getenv('DB_NAME'), 27 | 'username' => getenv('DB_AUTH_USERNAME'), 28 | 'password' => getenv('DB_AUTH_PASSWORD'), 29 | 'charset' => 'utf8', 30 | 'collation' => 'utf8_unicode_ci', 31 | 'prefix' => '', 32 | ], 33 | 34 | 'pgsql' => [ 35 | 'driver' => 'pgsql', 36 | 'host' => 'localhost', 37 | 'database' => 'homestead', 38 | 'username' => 'homestead', 39 | 'password' => 'secret', 40 | 'charset' => 'utf8', 41 | 'prefix' => '', 42 | 'schema' => 'public', 43 | ], 44 | 45 | ], 46 | 47 | ]; 48 | -------------------------------------------------------------------------------- /app/config/mail.php: -------------------------------------------------------------------------------- 1 | 'smtp', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | SMTP Host Address 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may provide the host address of the SMTP server used by your 26 | | applications. A default option is provided that is compatible with 27 | | the Mailgun mail service which will provide reliable deliveries. 28 | | 29 | */ 30 | 31 | 'host' => getenv('MAIL_SMTP_HOST'), 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | SMTP Host Port 36 | |-------------------------------------------------------------------------- 37 | | 38 | | This is the SMTP port used by your application to deliver e-mails to 39 | | users of the application. Like the host we have set this value to 40 | | stay compatible with the Mailgun e-mail application by default. 41 | | 42 | */ 43 | 44 | 'port' => getenv('MAIL_SMTP_PORT'), 45 | 46 | /* 47 | |-------------------------------------------------------------------------- 48 | | Global "From" Address 49 | |-------------------------------------------------------------------------- 50 | | 51 | | You may wish for all e-mails sent by your application to be sent from 52 | | the same address. Here, you may specify a name and address that is 53 | | used globally for all e-mails that are sent by your application. 54 | | 55 | */ 56 | 57 | 'from' => ['address' => getenv('MAIL_FROM_ADDRESS'), 'name' => getenv('MAIL_FROM_NAME')], 58 | 59 | /* 60 | |-------------------------------------------------------------------------- 61 | | E-Mail Encryption Protocol 62 | |-------------------------------------------------------------------------- 63 | | 64 | | Here you may specify the encryption protocol that should be used when 65 | | the application send e-mail messages. A sensible default using the 66 | | transport layer security protocol should provide great security. 67 | | 68 | */ 69 | 70 | 'encryption' => 'tls', 71 | 72 | /* 73 | |-------------------------------------------------------------------------- 74 | | SMTP Server Username 75 | |-------------------------------------------------------------------------- 76 | | 77 | | If your SMTP server requires a username for authentication, you should 78 | | set it here. This will get used to authenticate with your server on 79 | | connection. You may also set the "password" value below this one. 80 | | 81 | */ 82 | 83 | 'username' => getenv('MAIL_USERNAME'), 84 | 85 | /* 86 | |-------------------------------------------------------------------------- 87 | | SMTP Server Password 88 | |-------------------------------------------------------------------------- 89 | | 90 | | Here you may set the password required by your SMTP server to send out 91 | | messages from your application. This will be given to the server on 92 | | connection so that the application will be able to send messages. 93 | | 94 | */ 95 | 96 | 'password' => getenv('MAIL_PASSWORD'), 97 | 98 | /* 99 | |-------------------------------------------------------------------------- 100 | | Sendmail System Path 101 | |-------------------------------------------------------------------------- 102 | | 103 | | When using the "sendmail" driver to send e-mails, we will need to know 104 | | the path to where Sendmail lives on this server. A default path has 105 | | been provided here, which will work well on most of your systems. 106 | | 107 | */ 108 | 109 | 'sendmail' => '/usr/sbin/sendmail -bs', 110 | 111 | /* 112 | |-------------------------------------------------------------------------- 113 | | Mail "Pretend" 114 | |-------------------------------------------------------------------------- 115 | | 116 | | When this option is enabled, e-mail will not actually be sent over the 117 | | web and will instead be written to your application's logs files so 118 | | you may inspect the message. This is great for local development. 119 | | 120 | */ 121 | 122 | 'pretend' => false, 123 | 124 | ]; 125 | -------------------------------------------------------------------------------- /app/config/packages/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fasilkk/SampleRestAPI/9080ffddc9414bb0cdc673918f79ea6ac0a4d70b/app/config/packages/.gitkeep -------------------------------------------------------------------------------- /app/config/queue.php: -------------------------------------------------------------------------------- 1 | 'sync', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Queue Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may configure the connection information for each server that 26 | | is used by your application. A default configuration has been added 27 | | for each back-end shipped with Laravel. You are free to add more. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'beanstalkd' => [ 38 | 'driver' => 'beanstalkd', 39 | 'host' => 'localhost', 40 | 'queue' => 'default', 41 | 'ttr' => 60, 42 | ], 43 | 44 | 'sqs' => [ 45 | 'driver' => 'sqs', 46 | 'key' => 'your-public-key', 47 | 'secret' => 'your-secret-key', 48 | 'queue' => 'your-queue-url', 49 | 'region' => 'us-east-1', 50 | ], 51 | 52 | 'iron' => [ 53 | 'driver' => 'iron', 54 | 'host' => 'mq-aws-us-east-1.iron.io', 55 | 'token' => 'your-token', 56 | 'project' => 'your-project-id', 57 | 'queue' => 'your-queue-name', 58 | 'encrypt' => true, 59 | ], 60 | 61 | 'redis' => [ 62 | 'driver' => 'redis', 63 | 'queue' => 'default', 64 | ], 65 | 66 | ], 67 | 68 | /* 69 | |-------------------------------------------------------------------------- 70 | | Failed Queue Jobs 71 | |-------------------------------------------------------------------------- 72 | | 73 | | These options configure the behavior of failed queue job logging so you 74 | | can control which database and table are used to store the jobs that 75 | | have failed. You may change them to any database / table you wish. 76 | | 77 | */ 78 | 79 | 'failed' => [ 80 | 81 | 'database' => 'mysql', 'table' => 'failed_jobs', 82 | 83 | ], 84 | 85 | ]; 86 | -------------------------------------------------------------------------------- /app/config/remote.php: -------------------------------------------------------------------------------- 1 | 'production', 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Remote Server Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | These are the servers that will be accessible via the SSH task runner 24 | | facilities of Laravel. This feature radically simplifies executing 25 | | tasks on your servers, such as deploying out these applications. 26 | | 27 | */ 28 | 29 | 'connections' => [ 30 | 31 | 'production' => [ 32 | 'host' => '', 33 | 'username' => '', 34 | 'password' => '', 35 | 'key' => '', 36 | 'keyphrase' => '', 37 | 'root' => '/var/www', 38 | ], 39 | 40 | ], 41 | 42 | /* 43 | |-------------------------------------------------------------------------- 44 | | Remote Server Groups 45 | |-------------------------------------------------------------------------- 46 | | 47 | | Here you may list connections under a single group name, which allows 48 | | you to easily access all of the servers at once using a short name 49 | | that is extremely easy to remember, such as "web" or "database". 50 | | 51 | */ 52 | 53 | 'groups' => [ 54 | 55 | 'web' => ['production'], 56 | 57 | ], 58 | 59 | ]; 60 | -------------------------------------------------------------------------------- /app/config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => '', 19 | 'secret' => '', 20 | ], 21 | 22 | 'mandrill' => [ 23 | 'secret' => '', 24 | ], 25 | 26 | 'stripe' => [ 27 | 'model' => 'User', 28 | 'secret' => '', 29 | ], 30 | 31 | ]; 32 | -------------------------------------------------------------------------------- /app/config/session.php: -------------------------------------------------------------------------------- 1 | 'file', 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Session Lifetime 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may specify the number of minutes that you wish the session 27 | | to be allowed to remain idle before it expires. If you want them 28 | | to immediately expire on the browser closing, set that option. 29 | | 30 | */ 31 | 32 | 'lifetime' => 120, 33 | 34 | 'expire_on_close' => false, 35 | 36 | /* 37 | |-------------------------------------------------------------------------- 38 | | Session File Location 39 | |-------------------------------------------------------------------------- 40 | | 41 | | When using the native session driver, we need a location where session 42 | | files may be stored. A default has been set for you but a different 43 | | location may be specified. This is only needed for file sessions. 44 | | 45 | */ 46 | 47 | 'files' => storage_path().'/sessions', 48 | 49 | /* 50 | |-------------------------------------------------------------------------- 51 | | Session Database Connection 52 | |-------------------------------------------------------------------------- 53 | | 54 | | When using the "database" or "redis" session drivers, you may specify a 55 | | connection that should be used to manage these sessions. This should 56 | | correspond to a connection in your database configuration options. 57 | | 58 | */ 59 | 60 | 'connection' => null, 61 | 62 | /* 63 | |-------------------------------------------------------------------------- 64 | | Session Database Table 65 | |-------------------------------------------------------------------------- 66 | | 67 | | When using the "database" session driver, you may specify the table we 68 | | should use to manage the sessions. Of course, a sensible default is 69 | | provided for you; however, you are free to change this as needed. 70 | | 71 | */ 72 | 73 | 'table' => 'sessions', 74 | 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Session Sweeping Lottery 78 | |-------------------------------------------------------------------------- 79 | | 80 | | Some session drivers must manually sweep their storage location to get 81 | | rid of old sessions from storage. Here are the chances that it will 82 | | happen on a given request. By default, the odds are 2 out of 100. 83 | | 84 | */ 85 | 86 | 'lottery' => [2, 100], 87 | 88 | /* 89 | |-------------------------------------------------------------------------- 90 | | Session Cookie Name 91 | |-------------------------------------------------------------------------- 92 | | 93 | | Here you may change the name of the cookie used to identify a session 94 | | instance by ID. The name specified here will get used every time a 95 | | new session cookie is created by the framework for every driver. 96 | | 97 | */ 98 | 99 | 'cookie' => 'laravel_session', 100 | 101 | /* 102 | |-------------------------------------------------------------------------- 103 | | Session Cookie Path 104 | |-------------------------------------------------------------------------- 105 | | 106 | | The session cookie path determines the path for which the cookie will 107 | | be regarded as available. Typically, this will be the root path of 108 | | your application but you are free to change this when necessary. 109 | | 110 | */ 111 | 112 | 'path' => '/', 113 | 114 | /* 115 | |-------------------------------------------------------------------------- 116 | | Session Cookie Domain 117 | |-------------------------------------------------------------------------- 118 | | 119 | | Here you may change the domain of the cookie used to identify a session 120 | | in your application. This will determine which domains the cookie is 121 | | available to in your application. A sensible default has been set. 122 | | 123 | */ 124 | 125 | 'domain' => null, 126 | 127 | /* 128 | |-------------------------------------------------------------------------- 129 | | HTTPS Only Cookies 130 | |-------------------------------------------------------------------------- 131 | | 132 | | By setting this option to true, session cookies will only be sent back 133 | | to the server if the browser has a HTTPS connection. This will keep 134 | | the cookie from being sent to you if it can not be done securely. 135 | | 136 | */ 137 | 138 | 'secure' => false, 139 | 140 | ]; 141 | -------------------------------------------------------------------------------- /app/config/stage/app.php: -------------------------------------------------------------------------------- 1 | true, 17 | 18 | 'providers' => [ 19 | 20 | 'Illuminate\Foundation\Providers\ArtisanServiceProvider', 21 | 'Illuminate\Auth\AuthServiceProvider', 22 | 'Illuminate\Cache\CacheServiceProvider', 23 | 'Illuminate\Session\CommandsServiceProvider', 24 | 'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider', 25 | 'Illuminate\Routing\ControllerServiceProvider', 26 | 'Illuminate\Cookie\CookieServiceProvider', 27 | 'Illuminate\Database\DatabaseServiceProvider', 28 | 'Illuminate\Encryption\EncryptionServiceProvider', 29 | 'Illuminate\Filesystem\FilesystemServiceProvider', 30 | 'Illuminate\Hashing\HashServiceProvider', 31 | 'Illuminate\Html\HtmlServiceProvider', 32 | 'Illuminate\Log\LogServiceProvider', 33 | 'Illuminate\Mail\MailServiceProvider', 34 | 'Illuminate\Database\MigrationServiceProvider', 35 | 'Illuminate\Pagination\PaginationServiceProvider', 36 | 'Illuminate\Queue\QueueServiceProvider', 37 | 'Illuminate\Redis\RedisServiceProvider', 38 | 'Illuminate\Remote\RemoteServiceProvider', 39 | 'Illuminate\Auth\Reminders\ReminderServiceProvider', 40 | 'Illuminate\Database\SeedServiceProvider', 41 | 'Illuminate\Session\SessionServiceProvider', 42 | 'Illuminate\Translation\TranslationServiceProvider', 43 | 'Illuminate\Validation\ValidationServiceProvider', 44 | 'Illuminate\View\ViewServiceProvider', 45 | 'Illuminate\Workbench\WorkbenchServiceProvider', 46 | 'Way\Generators\GeneratorsServiceProvider', 47 | 'Laracasts\Validation\ValidationServiceProvider', 48 | 49 | ], 50 | 51 | ]; 52 | -------------------------------------------------------------------------------- /app/config/stage/database.php: -------------------------------------------------------------------------------- 1 | [ 22 | 23 | 'mysql' => [ 24 | 'driver' => 'mysql', 25 | 'host' => 'localhost', 26 | 'database' => 'molio', 27 | 'username' => 'root', 28 | 'password' => 'start', 29 | 'charset' => 'utf8', 30 | 'collation' => 'utf8_unicode_ci', 31 | 'prefix' => '', 32 | ], 33 | 34 | 'pgsql' => [ 35 | 'driver' => 'pgsql', 36 | 'host' => 'localhost', 37 | 'database' => 'homestead', 38 | 'username' => 'homestead', 39 | 'password' => 'secret', 40 | 'charset' => 'utf8', 41 | 'prefix' => '', 42 | 'schema' => 'public', 43 | 44 | ], 45 | 46 | ], 47 | 48 | ]; 49 | -------------------------------------------------------------------------------- /app/config/test/database.php: -------------------------------------------------------------------------------- 1 | [ 22 | 23 | 'mysql' => [ 24 | 'driver' => 'mysql', 25 | 'host' => 'localhost', 26 | 'database' => 'api-t01', 27 | 'username' => 'ciApi2014', 28 | 'password' => 'ciApi2014!', 29 | 'charset' => 'utf8', 30 | 'collation' => 'utf8_unicode_ci', 31 | 'prefix' => '', 32 | ], 33 | 34 | ], 35 | 36 | ]; 37 | -------------------------------------------------------------------------------- /app/config/testing/cache.php: -------------------------------------------------------------------------------- 1 | 'array', 19 | 20 | ]; 21 | -------------------------------------------------------------------------------- /app/config/testing/database.php: -------------------------------------------------------------------------------- 1 | 'mysql', 6 | 7 | 'mysql' => [ 8 | 'driver' => 'mysql', 9 | 'host' => 'localhost', 10 | 'database' => 'userapitester', 11 | 'username' => 'root', 12 | 'password' => 'root123#', 13 | 'charset' => 'utf8', 14 | 'collation' => 'utf8_unicode_ci', 15 | 'prefix' => '', 16 | ], 17 | 18 | ]; 19 | -------------------------------------------------------------------------------- /app/config/testing/session.php: -------------------------------------------------------------------------------- 1 | 'array', 20 | 21 | ]; 22 | -------------------------------------------------------------------------------- /app/config/view.php: -------------------------------------------------------------------------------- 1 | [__DIR__.'/../views'], 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Pagination View 21 | |-------------------------------------------------------------------------- 22 | | 23 | | This view will be used to render the pagination link output, and can 24 | | be easily customized here to show any view you like. A clean view 25 | | compatible with Twitter's Bootstrap is given to you by default. 26 | | 27 | */ 28 | 29 | 'pagination' => 'pagination::slider-3', 30 | 31 | ]; 32 | -------------------------------------------------------------------------------- /app/config/workbench.php: -------------------------------------------------------------------------------- 1 | '', 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Workbench Author E-Mail Address 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Like the option above, your e-mail address is used when generating new 24 | | workbench packages. The e-mail is placed in your composer.json file 25 | | automatically after the package is created by the workbench tool. 26 | | 27 | */ 28 | 29 | 'email' => '', 30 | 31 | ]; 32 | -------------------------------------------------------------------------------- /app/controllers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fasilkk/SampleRestAPI/9080ffddc9414bb0cdc673918f79ea6ac0a4d70b/app/controllers/.gitkeep -------------------------------------------------------------------------------- /app/controllers/ApiController.php: -------------------------------------------------------------------------------- 1 | setStausCode(404)->responseWithError($message); 25 | } 26 | 27 | /** 28 | * @param string $message 29 | * 30 | * @return json 31 | */ 32 | public function responseWithError($message = '') 33 | { 34 | return $this->response([ 35 | 'error' => ['message' => $message, 36 | 'status_code' => $this->getStausCode(), ], 37 | 38 | ]); 39 | } 40 | 41 | /** 42 | * @param $data 43 | * @param array $headers 44 | * 45 | * @return json 46 | */ 47 | public function response($data, $headers = []) 48 | { 49 | return Response::json($data, $this->getStausCode(), $headers); 50 | } 51 | 52 | /** 53 | * @return int 54 | */ 55 | public function getStausCode() 56 | { 57 | return $this->stausCode; 58 | } 59 | 60 | /** 61 | * @param int $stausCode 62 | * 63 | * @return $this 64 | */ 65 | public function setStausCode($stausCode) 66 | { 67 | $this->stausCode = $stausCode; 68 | 69 | return $this; 70 | } 71 | 72 | /** 73 | * @param $message 74 | * 75 | * @return json 76 | */ 77 | public function responseSuccess($message) 78 | { 79 | return $this->setStausCode(IlluminateResponse::HTTP_OK)->response(['message' => $message]); 80 | } 81 | 82 | /** 83 | * @param $data 84 | * 85 | * @return json 86 | */ 87 | public function responseSuccessWithOnlyData($data) 88 | { 89 | return $this->setStausCode(IlluminateResponse::HTTP_OK)->response(['data' => $data]); 90 | } 91 | 92 | /** 93 | * @param $message 94 | * 95 | * @return json 96 | */ 97 | public function responseForbidden($message) 98 | { 99 | return $this->setStausCode(IlluminateResponse::HTTP_FORBIDDEN)->responseWithError([$message]); 100 | } 101 | 102 | /** 103 | * @param $message 104 | * 105 | * @return json 106 | */ 107 | public function responseInternalError($message) 108 | { 109 | return $this->setStausCode(IlluminateResponse::HTTP_INTERNAL_SERVER_ERROR)->responseWithError([$message]); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /app/controllers/BaseController.php: -------------------------------------------------------------------------------- 1 | layout)) { 13 | $this->layout = View::make($this->layout); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/controllers/ContactController.php: -------------------------------------------------------------------------------- 1 | beforeFilter('auth.basic'); 22 | 23 | //validations 24 | $this->contactGroupFormValidation = $contactGroupFormValidation; 25 | $this->contactFormValidation = $contactFormValidation; 26 | 27 | //data mapper 28 | $this->groupDataMapper = $groupDataMapper; 29 | $this->contactDataMapper = $contactDataMapper; 30 | 31 | // $this->contactFormValidation->setUserId(Auth::user()->id); 32 | } 33 | 34 | /** 35 | * Display a listing of the resource. 36 | * GET /contacts. 37 | * 38 | * @return Response 39 | */ 40 | public function index() 41 | { 42 | //current user object 43 | $user = Auth::user(); 44 | 45 | if ($user->groups != null) { 46 | return $this->responseSuccessWithOnlyData($this->groupDataMapper->mapCollection($user->groups->toArray())); 47 | } else { 48 | return $this->responseSuccessWithOnlyData([]); 49 | } 50 | } 51 | 52 | /** 53 | * Display a listing of contacts 54 | * GET /contacts. 55 | * 56 | * @return Response 57 | */ 58 | public function contactIndex() 59 | { 60 | //input the nummbers array "numbers[]" 61 | $inputs = Input::only('numbers'); 62 | 63 | //user object 64 | $user = Auth::user(); 65 | 66 | try { 67 | if (is_array($inputs['numbers'])) { 68 | foreach ($inputs['numbers'] as $value) { 69 | $data = ['number' => $value]; 70 | 71 | $this->contactFormValidation->validate($data); 72 | } 73 | 74 | $contacts = Contact::whereIn('number', $inputs['numbers'])->where('user_id', '=', $user->id)->get(); 75 | 76 | return $this->responseSuccessWithOnlyData($this->contactDataMapper->mapCollection($contacts->toArray())); 77 | } 78 | 79 | return $this->responseWithError(['numbers[]' => 'Enter Valid Numbers']); 80 | } catch (FormValidationException $e) { 81 | //returning errors from Exception 82 | //Format = error { message : {"field" :['error'], "field2" :['error2'],.... } } 83 | return $this->responseWithError($e->getErrors()->toArray()); 84 | } 85 | } 86 | 87 | /** 88 | * Create a new Contact Group 89 | * POST /contacts. 90 | * 91 | * @return Response 92 | */ 93 | public function store() 94 | { 95 | //current user object 96 | $user = Auth::user(); 97 | 98 | $inputs = Input::only('name'); 99 | 100 | //validating Inputs 101 | try { 102 | $this->contactGroupFormValidation->validate($inputs); 103 | 104 | //now store data to group table 105 | $grpTable = new \Group(); 106 | $grpTable->name = $inputs['name']; 107 | $grpTable->user()->associate($user)->save(); 108 | 109 | return $this->responseSuccess('Successfully Created New Group !'); 110 | } catch (FormValidationException $e) { 111 | //returning errors from Exception 112 | //Format = error : { message : {"field" :['error'], "field2" :['error2'],.... } } 113 | return $this->responseWithError($e->getErrors()->toArray()); 114 | } 115 | } 116 | 117 | /** 118 | * Update the group data 119 | * PUT /contacts/groups/{id}. 120 | * 121 | * @param Model $group 122 | * 123 | * @return Response 124 | */ 125 | public function update($group) 126 | { 127 | 128 | //user Object 129 | $user = Auth::user(); 130 | 131 | //checking the requested id belongs to the logged in user 132 | if ($group->user->id == $user->id) { 133 | try { 134 | $inputs = Input::only('name'); 135 | //validating Inputs 136 | $this->contactGroupFormValidation->validate($inputs); 137 | $group->name = $inputs['name']; 138 | $group->save(); 139 | 140 | return $this->responseSuccess('Successfully Updated Group !'); 141 | } catch (FormValidationException $e) { 142 | //returning errors from Exception 143 | //Format = error { message : {"field" :['error'], "field2" :['error2'],.... } } 144 | return $this->responseWithError($e->getErrors()->toArray()); 145 | } 146 | } else { 147 | return $this->responseForbidden('You are not authorized to access this data !'); 148 | } 149 | } 150 | 151 | /** 152 | * Delete a group by its id 153 | * DELETE /contacts/groups/{group}. 154 | * 155 | * @param Model $group 156 | * 157 | * @return Response 158 | */ 159 | public function destroy($group) 160 | { 161 | //user Object 162 | $user = Auth::user(); 163 | 164 | //checking the requested id belongs to the logged in user 165 | if ($group->user->id == $user->id) { 166 | $group->delete(); 167 | 168 | return $this->responseSuccess('Successfully deleted the group !'); 169 | } 170 | 171 | return $this->responseForbidden('You are not authorized to access this data !'); 172 | } 173 | 174 | /** 175 | * get all the contacts of a group 176 | * GET /contacts/groups/{groupId}/links. 177 | * 178 | * @param Model $group 179 | * 180 | * @return Response 181 | */ 182 | public function getContact($group) 183 | { 184 | 185 | //current user object 186 | $user = Auth::user(); 187 | 188 | if ($user->groups != null) { 189 | return $this->responseSuccessWithOnlyData($this->contactDataMapper->mapCollection($group->contact->toArray())); 190 | } else { 191 | return $this->responseSuccessWithOnlyData([]); 192 | } 193 | } 194 | 195 | /** 196 | * Create new contacts in a group 197 | * POST /contacts/groups/{groupId}/links. 198 | * 199 | * @param Model $group 200 | * 201 | * @return Response 202 | */ 203 | public function postContact($group) 204 | { 205 | 206 | //input the nummbers array "numbers[]" 207 | $inputs = Input::only('numbers'); 208 | 209 | //user object 210 | $user = Auth::user(); 211 | 212 | if ($group->user->id == $user->id) { 213 | try { 214 | if (is_array($inputs['numbers'])) { 215 | foreach ($inputs['numbers'] as $value) { 216 | $data = ['number' => $value]; 217 | 218 | $this->contactFormValidation->validate($data); 219 | } 220 | 221 | foreach ($inputs['numbers'] as $value) { 222 | $data = ['number' => $value]; 223 | 224 | $contact = new Contact($data); 225 | $contact->user()->associate($user); 226 | $contact->group()->associate($group); 227 | $contact->save(); 228 | } 229 | 230 | return $this->responseSuccess('Successfully Added Contacts !'); 231 | } 232 | 233 | return $this->responseWithError(['numbers[]' => 'Enter Valid Numbers']); 234 | } catch (FormValidationException $e) { 235 | 236 | //returning errors from Exception 237 | //Format = error { message : {"field" :['error'], "field2" :['error2'],.... } } 238 | return $this->responseWithError($e->getErrors()->toArray()); 239 | } 240 | } 241 | 242 | return $this->responseForbidden('You are not authorized to access this data !'); 243 | } 244 | 245 | /** 246 | * Delete contacts from a group 247 | * DELETE /contacts/groups/{groupId}/links. 248 | * 249 | * @param Model $group 250 | * 251 | * @return Response 252 | */ 253 | public function deleteContact($group) 254 | { 255 | 256 | //input the nummbers array "numbers[]" 257 | $inputs = Input::only('numbers'); 258 | 259 | //user object 260 | $user = Auth::user(); 261 | 262 | if ($group->user->id == $user->id) { 263 | try { 264 | if (is_array($inputs['numbers'])) { 265 | foreach ($inputs['numbers'] as $value) { 266 | $data = ['number' => $value]; 267 | 268 | $this->contactFormValidation->validate($data); 269 | } 270 | 271 | $deleteFlag = 0; 272 | 273 | foreach ($inputs['numbers'] as $value) { 274 | $contact = Contact::whereNumber($value)->first(); 275 | 276 | if (isset($contact->id) && $group->id == $contact->group_id) { 277 | $contact->delete(); 278 | $deleteFlag++; 279 | } 280 | } 281 | 282 | if ($deleteFlag == 0) { 283 | return $this->responseWithError('No contacts Deleted !'); 284 | } elseif ($deleteFlag < count($inputs['numbers'])) { 285 | return $this->responseWithError('some contacts Deleted !'); 286 | } else { 287 | return $this->responseSuccess('Successfully Deleted Contacts !'); 288 | } 289 | } 290 | 291 | return $this->responseWithError(['numbers[]' => 'Enter Valid Numbers']); 292 | } catch (FormValidationException $e) { 293 | //returning errors from Exception 294 | //Format = error { message : {"field" :['error'], "field2" :['error2'],.... } } 295 | return $this->responseWithError($e->getErrors()->toArray()); 296 | } 297 | } else { 298 | return $this->responseForbidden('You are not authorized to access this data !'); 299 | } 300 | } 301 | } 302 | -------------------------------------------------------------------------------- /app/controllers/FavoriteController.php: -------------------------------------------------------------------------------- 1 | beforeFilter('auth.basic'); 23 | $param = Route::current()->getParameter('favorite'); 24 | $this->beforeFilter('favFilter:'.$param, ['only' => 'show']); 25 | 26 | //validations 27 | $this->favoriteFormValidation = $favoriteFormValidation; 28 | $this->favoriteFormUpdateValidation = $favoriteFormUpdateValidation; 29 | 30 | //data mapper 31 | $this->favoriteDataMapper = $favoriteDataMapper; 32 | } 33 | 34 | /** 35 | * Display a listing of favorites of the user 36 | * GET api/favorite. 37 | * 38 | * @return json 39 | */ 40 | public function index() 41 | { 42 | //get logged user 43 | $user = Auth::user(); 44 | 45 | //return favorite datas 46 | return $this->responseSuccessWithOnlyData($this->favoriteDataMapper->mapCollection($user->favorite->toArray())); 47 | } 48 | 49 | /** 50 | * create new favorite for the user 51 | * GET /favorite/create. 52 | * 53 | * @return Response 54 | */ 55 | public function store() 56 | { 57 | $inputs = Input::only('name', 'address', 'lat', 'lng'); 58 | 59 | //validating Inputs 60 | try { 61 | $this->favoriteFormValidation->validate($inputs); 62 | 63 | //now store data to favorite table 64 | $user = Auth::user(); 65 | $favTable = new \Favorite(); 66 | $favTable->name = $inputs['name']; 67 | $favTable->address = $inputs['address']; 68 | $favTable->lat = $inputs['lat']; 69 | $favTable->lng = $inputs['lng']; 70 | $favTable->user()->associate($user)->save(); 71 | 72 | return $this->responseSuccess('Successfully Created Favorite Item !'); 73 | } catch (FormValidationException $e) { 74 | //returning errors from Exception 75 | //Format = error : { message : {"field" :['error'], "field2" :['error2'],.... } } 76 | return $this->responseWithError($e->getErrors()->toArray()); 77 | } 78 | } 79 | 80 | /** 81 | * Display the count of the favourate item 82 | * GET /favorite/{id}. 83 | * 84 | * @return json 85 | */ 86 | public function count() 87 | { 88 | $user = Auth::user(); 89 | 90 | return $this->responseSuccessWithOnlyData( 91 | [ 92 | 'count' => $user->favorite()->count(), 93 | ] 94 | ); 95 | } 96 | 97 | /** 98 | * Update the favorite iten. 99 | * PUT /favorite/{id}. 100 | * 101 | * @param int $favorite 102 | * 103 | * @return json 104 | */ 105 | public function update($favorite) 106 | { 107 | $user = Auth::user(); 108 | 109 | //checking the requested id belongs to the logged in user 110 | if ($favorite->user->id == $user->id) { 111 | try { 112 | $inputs = Input::only('name'); 113 | //validating Inputs 114 | $this->favoriteFormUpdateValidation->validate($inputs); 115 | $favorite->name = $inputs['name']; 116 | $favorite->save(); 117 | 118 | return $this->responseSuccess('Successfully Updated favorite item !'); 119 | } catch (FormValidationException $e) { 120 | //returning errors from Exception 121 | //Format = error { message : {"field" :['error'], "field2" :['error2'],.... } } 122 | return $this->responseWithError($e->getErrors()->toArray()); 123 | } 124 | } else { 125 | return $this->responseForbidden('This service is Unavailable !'); 126 | } 127 | } 128 | 129 | /** 130 | * Remove the favorite item 131 | * DELETE /favorite/{id}. 132 | * 133 | * @param int $favorite 134 | * 135 | * @return json 136 | */ 137 | public function destroy($favorite) 138 | { 139 | $user = Auth::user(); 140 | 141 | //checking the requested id belongs to the logged in user 142 | if ($favorite->user->id == $user->id) { 143 | $favorite->delete(); 144 | 145 | return $this->responseSuccess('Successfully Deleted favorite item !'); 146 | } else { 147 | return $this->responseForbidden('This service is Unavailable !'); 148 | } 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /app/controllers/HomeController.php: -------------------------------------------------------------------------------- 1 | responseForbidden('associated user not found !'); 15 | 16 | case Password::REMINDER_SENT: 17 | return $this->responseSuccess('password token sent successfully to your email !'); 18 | } 19 | } 20 | 21 | /** 22 | * Display the password reset view for the given token. 23 | * 24 | * @param string $token 25 | * 26 | * @return Response 27 | */ 28 | public function getReset($token = null) 29 | { 30 | if (is_null($token)) { 31 | App::abort(404); 32 | } 33 | 34 | return $this->response(['token' => $token]); 35 | } 36 | 37 | /** 38 | * Handle a POST request to reset a user's password. 39 | * 40 | * @return Response 41 | */ 42 | public function postReset() 43 | { 44 | $credentials = Input::only( 45 | 'email', 'password', 'password_confirmation', 'token' 46 | ); 47 | 48 | $response = Password::reset($credentials, function ($user, $password) { 49 | $user->password = $password; 50 | 51 | $user->save(); 52 | }); 53 | 54 | switch ($response) { 55 | case Password::INVALID_PASSWORD: 56 | case Password::INVALID_TOKEN: 57 | case Password::INVALID_USER: 58 | return $this->responseInternalError('Somthin went wrong please try again later :('); 59 | 60 | case Password::PASSWORD_RESET: 61 | return $this->responseSuccess('Password Reset Succesfully !'); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /app/controllers/UserController.php: -------------------------------------------------------------------------------- 1 | beforeFilter('auth.basic', ['except' => ['login', 'register']]); 30 | $id = Route::current()->getParameter('user'); 31 | $this->beforeFilter('userstatus:'.$id, ['only' => 'show']); 32 | 33 | $this->registrationform = $registrationForm; 34 | $this->loginform = $loginform; 35 | $this->updateform = $updateform; 36 | $this->userdatamapper = $userdatamapper; 37 | $this->passwordform = $passwordform; 38 | $this->imageuploadform = $imageuploadform; 39 | $this->contactForm = $contactForm; 40 | } 41 | 42 | /** 43 | * Display user data. 44 | * 45 | * @return json 46 | */ 47 | public function index() 48 | { 49 | return $this->response($this->userdatamapper->mapper(Auth::user()->toArray())); 50 | } 51 | 52 | /** 53 | * Register new user. 54 | * 55 | * @return jsom 56 | */ 57 | public function register() 58 | { 59 | try { 60 | //get all input 61 | $inputs = Input::only('username', 'password', 'email', 'fname', 'lname', 'address'); 62 | 63 | // validating inputs required fields(username,password,email,fname,lname,address) and username and email fields are unique 64 | $this->registrationform->validate($inputs); 65 | 66 | $user = User::create(Input::only('username', 'password', 'email', 'fname', 'lname', 'address')); 67 | Auth::login($user); 68 | 69 | return $this->responseSuccess('Successfully Registered !'); 70 | } catch (FormValidationException $e) { 71 | //returning errors from Exception 72 | //Format = error : { message : {"field" :['error'], "field2" :['error2'],.... } } 73 | return $this->responseWithError($e->getErrors()->toArray()); 74 | } 75 | } 76 | 77 | /** 78 | * user login function. 79 | * 80 | * @throws \Laracasts\Validation\FormValidationException 81 | * 82 | * @return json 83 | */ 84 | public function login() 85 | { 86 | try { 87 | //get all input 88 | $inputs = Input::only('username', 'password'); 89 | $inputs['status'] = true; 90 | 91 | //validating username and password fields 92 | $this->loginform->validate($inputs); 93 | 94 | if (Auth::attempt($inputs)) { 95 | return $this->responseSuccess('Successfully Logged In !'); 96 | } else { 97 | return $this->responseForbidden('Enter valid credentials !'); 98 | } 99 | } catch (FormValidationException $e) { 100 | //returning errors from ValidationException 101 | //Format = error : { message : {"field" :['error'], "field2" :['error2'],.... } } 102 | return $this->responseWithError($e->getErrors()->toArray()); 103 | } 104 | } 105 | 106 | /** 107 | * user logout function. 108 | * 109 | * @return json 110 | */ 111 | public function logout() 112 | { 113 | //loggin out session 114 | Auth::logout(); 115 | Session::flush(); 116 | 117 | return $this->responseSuccess('Successfully Logged Out !'); 118 | } 119 | 120 | /** 121 | * user status. 122 | * 123 | * @return json 124 | */ 125 | public function status() 126 | { 127 | //return user status if enabled then says Active otherwise Deactivated 128 | return $this->response($this->userdatamapper->userStatus(Auth::user()->toArray())); 129 | } 130 | 131 | /** 132 | * Display the user information. 133 | * 134 | * @param int $id 135 | * 136 | * @return json 137 | */ 138 | public function show($id) 139 | { 140 | //showing current logged in user data 141 | return $this->response($this->userdatamapper->mapper(Auth::user()->toArray())); 142 | } 143 | 144 | /** 145 | * Update the user storage. 146 | * 147 | * @param int $id 148 | * 149 | * @return json 150 | */ 151 | public function update($id) 152 | { 153 | try { 154 | $inputs = Input::all('fname', 'lname', 'address', 'email'); 155 | 156 | //validation for input fields fname lname and address if exsist 157 | $this->updateform->validate($inputs); 158 | 159 | //updating user 160 | $user = Auth::user(); 161 | $user->fname = (Input::has('fname')) ? Input::get('fname') : $user->fname; 162 | $user->lname = (Input::has('lname')) ? Input::get('lname') : $user->lname; 163 | $user->address = (Input::has('address')) ? Input::get('address') : $user->address; 164 | $user->email = (Input::has('email')) ? Input::get('email') : $user->email; 165 | $user->save(); 166 | 167 | return $this->responseSuccess('Profile Updated successfully !'); 168 | } catch (FormValidationException $e) { 169 | //Format = error : { message : {"field" :['error'], "field2" :['error2'],.... } } 170 | return $this->responseWithError($e->getErrors()->toArray()); 171 | } 172 | } 173 | 174 | /** 175 | * Dissabling Current user account. 176 | * 177 | * @param int $id 178 | * 179 | * @return json 180 | */ 181 | public function destroy($id) 182 | { 183 | //gettin logged user 184 | $user = Auth::user(); 185 | 186 | //saving user status to false so that next time usercant login 187 | $user->status = false; 188 | $user->save(); 189 | 190 | //login out the current user 191 | Auth::logout(); 192 | 193 | return $this->responseSuccess('Successfully Disabled Account !'); 194 | } 195 | 196 | /** 197 | * Updating current user Image. 198 | * 199 | * @return json 200 | */ 201 | public function postUserImage() 202 | { 203 | try { 204 | if (!Input::hasFile('image')) { 205 | return $this->responseWithError('Please upload an image !'); 206 | } 207 | 208 | $user = Auth::user(); 209 | //validating image field 210 | $this->imageuploadform->validate(Input::all()); 211 | 212 | //saving user image 213 | $InputImageField = Input::file('image'); 214 | $destinationPath = 'public/img/'; 215 | $extension = $InputImageField->getClientOriginalExtension(); 216 | $filename = 'usr_'.Auth::user()->username.'.'.$extension; 217 | $InputImageField->move($destinationPath, $filename); 218 | $user->image = $filename; 219 | $user->save(); 220 | 221 | return $this->responseSuccess('Profile Picture Updated successfully !'); 222 | } catch (FormValidationException $e) { 223 | //validation fails 224 | //Format = error : { message : {"field" :['error'], "field2" :['error2'],.... } } 225 | return $this->responseForbidden($e->getErrors()->toArray()); 226 | } 227 | } 228 | 229 | /** 230 | * Updating current user password. 231 | * 232 | * @return json 233 | */ 234 | public function postUserPasswordUpdate() 235 | { 236 | try { 237 | //validating password field 238 | $this->passwordform->validate(Input::all()); 239 | 240 | //saving password 241 | $user = Auth::user(); 242 | $user->password = Input::get('password'); 243 | $user->save(); 244 | 245 | return $this->responseSuccess('Password Updated successfully !'); 246 | } catch (FormValidationException $e) { 247 | //validating fails 248 | //Format = error : { message : {"field" :['error'], "field2" :['error2'],.... } } 249 | return $this->responseForbidden($e->getErrors()->toArray()); 250 | } 251 | } 252 | 253 | /** 254 | * Updating/Create current user mobile number. 255 | * 256 | * @param $userId 257 | * 258 | * @return json 259 | */ 260 | public function mobileNumber($userId) 261 | { 262 | $user = Auth::user(); 263 | 264 | if ($userId == $user->id) { 265 | $input = Input::only('phone_number'); 266 | 267 | try { 268 | $this->contactForm->validate(['number'=>$input['phone_number']]); 269 | 270 | $profile = ($user->profile != null) ? Profile::find($user->profile->id) : new Profile(); 271 | 272 | $profile->phone_number = $input['phone_number']; 273 | 274 | $profile->user()->associate($user)->save(); 275 | 276 | return $this->responseSuccess('Successfully updated phone number !'); 277 | } catch (FormValidationException $e) { 278 | //validating fails 279 | //Format = error : { message : {"field" :['error'], "field2" :['error2'],.... } } 280 | return $this->responseForbidden($e->getErrors()->toArray()); 281 | } 282 | } else { 283 | return $this->responseForbidden('You are not authorized to access this page !'); 284 | } 285 | } 286 | } 287 | -------------------------------------------------------------------------------- /app/database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | -------------------------------------------------------------------------------- /app/database/migrations/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fasilkk/SampleRestAPI/9080ffddc9414bb0cdc673918f79ea6ac0a4d70b/app/database/migrations/.gitkeep -------------------------------------------------------------------------------- /app/database/migrations/2014_10_13_184737_create_users_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('username')->unique; 18 | $table->string('email')->unique; 19 | $table->string('password', 60); 20 | $table->string('fname', 60); 21 | $table->string('lname', 60); 22 | $table->text('address'); 23 | $table->string('image', 60)->nullable(); 24 | $table->string('remember_token')->nulllable(); 25 | $table->boolean('status')->default(true); 26 | $table->timestamps(); 27 | }); 28 | } 29 | 30 | /** 31 | * Reverse the migrations. 32 | * 33 | * @return void 34 | */ 35 | public function down() 36 | { 37 | Schema::drop('users'); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/database/migrations/2014_10_14_124202_create_password_reminders_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 17 | $table->string('token')->index(); 18 | $table->timestamp('created_at'); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | * 25 | * @return void 26 | */ 27 | public function down() 28 | { 29 | Schema::drop('password_reminders'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/database/migrations/2014_10_31_063959_create_favorites_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->integer('user_id')->unsigned(); 18 | $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); 19 | $table->string('name'); 20 | $table->text('address'); 21 | $table->decimal('lat', 10, 8); 22 | $table->decimal('lng', 11, 8); 23 | 24 | $table->timestamps(); 25 | }); 26 | } 27 | 28 | /** 29 | * Reverse the migrations. 30 | * 31 | * @return void 32 | */ 33 | public function down() 34 | { 35 | Schema::drop('favorites'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/database/migrations/2014_11_19_151007_create_user_profile_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->integer('user_id')->unsigned(); 18 | $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); 19 | $table->string('phone_number'); 20 | $table->timestamps(); 21 | }); 22 | } 23 | 24 | /** 25 | * Reverse the migrations. 26 | * 27 | * @return void 28 | */ 29 | public function down() 30 | { 31 | Schema::drop('user_profiles'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/database/migrations/2014_11_20_070730_create_contact_groups_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->integer('user_id')->unsigned(); 18 | $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); 19 | $table->string('name'); 20 | $table->boolean('status'); 21 | 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | * 29 | * @return void 30 | */ 31 | public function down() 32 | { 33 | Schema::drop('contact_groups'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/database/migrations/2014_11_20_070843_create_contacts_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->integer('user_id')->unsigned(); 18 | $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); 19 | $table->integer('group_id')->unsigned(); 20 | $table->foreign('group_id')->references('id')->on('contact_groups')->onDelete('cascade'); 21 | $table->string('name', 50); 22 | $table->string('number', 20); 23 | 24 | $table->timestamps(); 25 | }); 26 | } 27 | 28 | /** 29 | * Reverse the migrations. 30 | * 31 | * @return void 32 | */ 33 | public function down() 34 | { 35 | Schema::drop('contacts'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/database/seeds/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fasilkk/SampleRestAPI/9080ffddc9414bb0cdc673918f79ea6ac0a4d70b/app/database/seeds/.gitkeep -------------------------------------------------------------------------------- /app/database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | call('UsersTableSeeder'); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/database/seeds/UsersTableSeeder.php: -------------------------------------------------------------------------------- 1 | delete(); 13 | 14 | \DB::table('users')->insert([ 15 | 16 | 1 => [ 17 | 18 | 'username' => 'moliio_user', 19 | 'password' => Hash::make('123123'), 20 | 'email' => 'fasilkk.me@gmail.com', 21 | 'fname' => 'first', 22 | 'lname' => 'lirst', 23 | 'address' => 'molio #123, addrress', 24 | 25 | ], 26 | 27 | ]); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/filters.php: -------------------------------------------------------------------------------- 1 | [ 51 | 'code' => 401, 52 | 'message' => 'Invalid Credentials', 53 | ], 54 | ]; 55 | 56 | $headers = ['WWW-Authenticate' => 'Basic']; 57 | 58 | $response = Auth::basic('username'); 59 | 60 | if (!is_null($response)) { 61 | return Response::json($message, 401, $headers); 62 | } 63 | }); 64 | 65 | /* 66 | |-------------------------------------------------------------------------- 67 | | Guest Filter 68 | |-------------------------------------------------------------------------- 69 | | 70 | | The "guest" filter is the counterpart of the authentication filters as 71 | | it simply checks that the current user is not logged in. A redirect 72 | | response will be issued if they are, which you may freely change. 73 | | 74 | */ 75 | 76 | Route::filter('guest', function () { 77 | if (Auth::check()) { 78 | return Response::json(['error' => ['message' => 'You already Login']], 403); 79 | } 80 | }); 81 | 82 | /* 83 | |-------------------------------------------------------------------------- 84 | | User Information Filter 85 | |-------------------------------------------------------------------------- 86 | | 87 | | Limit access to only auth user and with only data param 88 | | 89 | */ 90 | 91 | Route::filter('userstatus', function ($route, $request, $response) { 92 | if ($response != 'data') { 93 | return Response::json(['error' => ['message' => 'This service is Unavailable !', 'status_code' =>'403']], 403); 94 | } 95 | }); 96 | 97 | /* 98 | |-------------------------------------------------------------------------- 99 | | User Information Filter 100 | |-------------------------------------------------------------------------- 101 | | 102 | | Limit access to only auth user and with only data param 103 | | 104 | */ 105 | 106 | Route::filter('favFilter', function ($route, $request, $response) { 107 | if ($response != 'count') { 108 | return Response::json(['error' => ['message' => 'This service is Unavailable !', 'status_code' =>'403']], 403); 109 | } 110 | }); 111 | 112 | /* 113 | |-------------------------------------------------------------------------- 114 | | CSRF Protection Filter 115 | |-------------------------------------------------------------------------- 116 | | 117 | | The CSRF filter is responsible for protecting your application against 118 | | cross-site request forgery attacks. If this special token in a user 119 | | session does not match the one given in this request, we'll bail. 120 | | 121 | */ 122 | 123 | Route::filter('csrf', function () { 124 | if (Session::token() != Input::get('_token')) { 125 | throw new Illuminate\Session\TokenMismatchException(); 126 | } 127 | }); 128 | -------------------------------------------------------------------------------- /app/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 18 | 'next' => 'Next »', 19 | 20 | ]; 21 | -------------------------------------------------------------------------------- /app/lang/en/reminders.php: -------------------------------------------------------------------------------- 1 | 'Passwords must be at least six characters and match the confirmation.', 17 | 18 | 'user' => "We can't find a user with that e-mail address.", 19 | 20 | 'token' => 'This password reset token is invalid.', 21 | 22 | 'sent' => 'Password reminder sent!', 23 | 24 | 'reset' => 'Password has been reset!', 25 | 26 | ]; 27 | -------------------------------------------------------------------------------- /app/lang/en/validation.php: -------------------------------------------------------------------------------- 1 | 'The :attribute must be accepted.', 17 | 'active_url' => 'The :attribute is not a valid URL.', 18 | 'after' => 'The :attribute must be a date after :date.', 19 | 'alpha' => 'The :attribute may only contain letters.', 20 | 'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.', 21 | 'alpha_num' => 'The :attribute may only contain letters and numbers.', 22 | 'array' => 'The :attribute must be an array.', 23 | 'before' => 'The :attribute must be a date before :date.', 24 | 'between' => [ 25 | 'numeric' => 'The :attribute must be between :min and :max.', 26 | 'file' => 'The :attribute must be between :min and :max kilobytes.', 27 | 'string' => 'The :attribute must be between :min and :max characters.', 28 | 'array' => 'The :attribute must have between :min and :max items.', 29 | ], 30 | 'boolean' => 'The :attribute field must be true or false.', 31 | 'confirmed' => 'The :attribute confirmation does not match.', 32 | 'date' => 'The :attribute is not a valid date.', 33 | 'date_format' => 'The :attribute does not match the format :format.', 34 | 'different' => 'The :attribute and :other must be different.', 35 | 'digits' => 'The :attribute must be :digits digits.', 36 | 'digits_between' => 'The :attribute must be between :min and :max digits.', 37 | 'email' => 'The :attribute must be a valid email address.', 38 | 'exists' => 'The selected :attribute is invalid.', 39 | 'image' => 'The :attribute must be an image.', 40 | 'in' => 'The selected :attribute is invalid.', 41 | 'integer' => 'The :attribute must be an integer.', 42 | 'ip' => 'The :attribute must be a valid IP address.', 43 | 'max' => [ 44 | 'numeric' => 'The :attribute may not be greater than :max.', 45 | 'file' => 'The :attribute may not be greater than :max kilobytes.', 46 | 'string' => 'The :attribute may not be greater than :max characters.', 47 | 'array' => 'The :attribute may not have more than :max items.', 48 | ], 49 | 'mimes' => 'The :attribute must be a file of type: :values.', 50 | 'min' => [ 51 | 'numeric' => 'The :attribute must be at least :min.', 52 | 'file' => 'The :attribute must be at least :min kilobytes.', 53 | 'string' => 'The :attribute must be at least :min characters.', 54 | 'array' => 'The :attribute must have at least :min items.', 55 | ], 56 | 'not_in' => 'The selected :attribute is invalid.', 57 | 'numeric' => 'The :attribute must be a number.', 58 | 'regex' => 'The :attribute format is invalid.', 59 | 'required' => 'The :attribute field is required.', 60 | 'required_if' => 'The :attribute field is required when :other is :value.', 61 | 'required_with' => 'The :attribute field is required when :values is present.', 62 | 'required_with_all' => 'The :attribute field is required when :values is present.', 63 | 'required_without' => 'The :attribute field is required when :values is not present.', 64 | 'required_without_all' => 'The :attribute field is required when none of :values are present.', 65 | 'same' => 'The :attribute and :other must match.', 66 | 'size' => [ 67 | 'numeric' => 'The :attribute must be :size.', 68 | 'file' => 'The :attribute must be :size kilobytes.', 69 | 'string' => 'The :attribute must be :size characters.', 70 | 'array' => 'The :attribute must contain :size items.', 71 | ], 72 | 'unique' => 'The :attribute has already been taken.', 73 | 'url' => 'The :attribute format is invalid.', 74 | 'timezone' => 'The :attribute must be a valid zone.', 75 | 76 | /* 77 | |-------------------------------------------------------------------------- 78 | | Custom Validation Language Lines 79 | |-------------------------------------------------------------------------- 80 | | 81 | | Here you may specify custom validation messages for attributes using the 82 | | convention "attribute.rule" to name the lines. This makes it quick to 83 | | specify a specific custom language line for a given attribute rule. 84 | | 85 | */ 86 | 87 | 'custom' => [ 88 | 'attribute-name' => [ 89 | 'rule-name' => 'custom-message', 90 | ], 91 | ], 92 | 93 | /* 94 | |-------------------------------------------------------------------------- 95 | | Custom Validation Attributes 96 | |-------------------------------------------------------------------------- 97 | | 98 | | The following language lines are used to swap attribute place-holders 99 | | with something more reader friendly such as E-Mail Address instead 100 | | of "email". This simply helps us make messages a little cleaner. 101 | | 102 | */ 103 | 104 | 'attributes' => [], 105 | 106 | ]; 107 | -------------------------------------------------------------------------------- /app/models/Contact.php: -------------------------------------------------------------------------------- 1 | belongsTo('Group'); 23 | } 24 | 25 | /** 26 | * return associated user. 27 | * 28 | * @return mixed 29 | */ 30 | public function user() 31 | { 32 | return $this->belongsTo('User'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/models/Favorite.php: -------------------------------------------------------------------------------- 1 | belongsTo('user'); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/models/Group.php: -------------------------------------------------------------------------------- 1 | belongsTo('user'); 12 | } 13 | 14 | public function contact() 15 | { 16 | return $this->hasMany('Contact'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/models/Profile.php: -------------------------------------------------------------------------------- 1 | belongsTo('User'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/models/User.php: -------------------------------------------------------------------------------- 1 | remember_token; 39 | } 40 | 41 | /** 42 | * get reminder email. 43 | * 44 | * @return string 45 | */ 46 | public function getReminderEmail() 47 | { 48 | return $this->email; 49 | } 50 | 51 | public function setPasswordAttribute($pass) 52 | { 53 | $this->attributes['password'] = Hash::make($pass); 54 | } 55 | 56 | /** 57 | * get user favorite datas. 58 | * 59 | * @return mixed 60 | */ 61 | public function favorite() 62 | { 63 | return $this->hasMany('Favorite'); 64 | } 65 | 66 | /** 67 | * get user profile datas. 68 | * 69 | * @return mixed 70 | */ 71 | public function profile() 72 | { 73 | return $this->hasOne('Profile'); 74 | } 75 | 76 | /** 77 | * get user contact datas. 78 | * 79 | * @return mixed 80 | */ 81 | public function contacts() 82 | { 83 | return $this->hasMany('Contact'); 84 | } 85 | 86 | /** 87 | * get user group datas. 88 | * 89 | * @return mixed 90 | */ 91 | public function groups() 92 | { 93 | return $this->hasMany('Group'); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /app/molio/ApiDataMapper/ContactDataMapper.php: -------------------------------------------------------------------------------- 1 | $contact['id'], 11 | 'Number' => $contact['number'], 12 | 13 | ]; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /app/molio/ApiDataMapper/DataMapper.php: -------------------------------------------------------------------------------- 1 | $favorite['id'], 11 | 'Name' => $favorite['name'], 12 | 'Address' => $favorite['address'], 13 | 'Latitude' => $favorite['lat'], 14 | 'Longitude' => $favorite['lng'], 15 | ]; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/molio/ApiDataMapper/GroupDataMapper.php: -------------------------------------------------------------------------------- 1 | $group['id'], 11 | 'Name' => $group['name'], 12 | 13 | ]; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /app/molio/ApiDataMapper/UserDataMapper.php: -------------------------------------------------------------------------------- 1 | $user['username'], 11 | 'first name'=> $user['fname'], 12 | 'last name' => $user['lname'], 13 | 'address' => $user['address'], 14 | ]; 15 | } 16 | 17 | public function userStatus($user) 18 | { 19 | return [ 20 | 21 | 'status' => ($user['status']) ? 'Active' : 'Deactivated', 22 | 23 | ]; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/molio/SiteHelpers/commonDebugHelpers.php: -------------------------------------------------------------------------------- 1 | '.print_r($value, true).''; 14 | 15 | if ($stop) { 16 | die(); 17 | } 18 | } 19 | 20 | /** 21 | * Print out debug informations for JavaScript. 22 | * 23 | * @param mixed $value 24 | * 25 | * @return string 26 | */ 27 | function DJ($value) 28 | { 29 | return '
'.print_r($value, true).'
'; 30 | 31 | die(); 32 | } 33 | 34 | /** 35 | * Print out Carbon format date time. 36 | * 37 | * @param object $attr 38 | * @param string $format 39 | */ 40 | function DT($attr, $format) 41 | { 42 | return $attr->formatLocalized($format); 43 | // return D($attr); 44 | } 45 | 46 | /** 47 | * Get config key. 48 | * 49 | * @param string $config 50 | * @param string $key 51 | * 52 | * @return string 53 | */ 54 | function CONFIG($config, $key) 55 | { 56 | if ($key == '') { 57 | return []; 58 | } 59 | 60 | $conf = Config::get($config); 61 | 62 | return $conf[$key]; 63 | } 64 | 65 | /* 66 | * SYSTEM 67 | */ 68 | 69 | if (!function_exists('env')) { 70 | /** 71 | * Get environment. 72 | * 73 | * @param string $env 74 | * 75 | * @return string 76 | */ 77 | function env($env) 78 | { 79 | return app()->env == $env; 80 | } 81 | } 82 | 83 | if (!function_exists('public_path')) { 84 | /** 85 | * Get public path. 86 | * 87 | * @return string 88 | */ 89 | function public_path($path = '') 90 | { 91 | return app()->make('path.public').($path ? '/'.$path : $path); 92 | } 93 | } 94 | 95 | /* 96 | * PATHS 97 | */ 98 | 99 | if (!function_exists('config_path')) { 100 | /** 101 | * Get the path to the cms/config folder. 102 | * 103 | * @param string $path 104 | * 105 | * @return string 106 | */ 107 | function config_path($file = '') 108 | { 109 | if (WB()) { 110 | return __DIR__.'/config/'.$file; 111 | } else { 112 | return app_path('config/packages/ewizycms/cms/'.$file); 113 | } 114 | } 115 | } 116 | 117 | if (!function_exists('themes_path')) { 118 | /** 119 | * Get the path to the storage folder. 120 | * 121 | * @param string $path 122 | * 123 | * @return string 124 | */ 125 | function themes_path($path = '') 126 | { 127 | return app('themes.path').($path ? '/'.$path : $path); 128 | } 129 | } 130 | 131 | if (!function_exists('theme_settings')) { 132 | /** 133 | * Get the path to the storage folder. 134 | * 135 | * @param string $path 136 | * 137 | * @return string 138 | */ 139 | function theme_settings($path = '') 140 | { 141 | require $path.'/theme.php'; 142 | 143 | return $THEME_SETTINGS; 144 | } 145 | } 146 | 147 | /* 148 | * TOOLS 149 | */ 150 | 151 | if (!function_exists('array_min_key')) { 152 | /** 153 | * Reduce an array with minimal key. 154 | * 155 | * @param array $array 156 | * @param mixed $min_key 157 | * 158 | * @return array 159 | */ 160 | function array_min_key($array, $min_key) 161 | { 162 | $min_val = $array[$min_key]; 163 | 164 | foreach ($array as $key => $value) { 165 | if ($value >= $min_val) { 166 | $tmp_array[$key] = $value; 167 | } 168 | } 169 | 170 | return $tmp_array; 171 | } 172 | } 173 | 174 | if (!function_exists('active')) { 175 | /** 176 | * Print out class=active if true. 177 | * 178 | * @param string $var 179 | * @param string $fix 180 | * 181 | * @return bool 182 | */ 183 | function active($var, $fix) 184 | { 185 | return Tool::isActive($var, $fix); 186 | } 187 | } 188 | 189 | if (!function_exists('checked')) { 190 | /** 191 | * Print out checked=checked if true. 192 | * 193 | * @param string $var 194 | * @param string $fix 195 | * 196 | * @return bool 197 | */ 198 | function checked($var, $fix) 199 | { 200 | return Tool::isChecked($var, $fix); 201 | } 202 | } 203 | 204 | if (!function_exists('selected')) { 205 | /** 206 | * Print out selected=selected if true. 207 | * 208 | * @param string $var 209 | * @param string $fix 210 | * 211 | * @return bool 212 | */ 213 | function selected($var, $fix) 214 | { 215 | return Tool::isSelected($var, $fix); 216 | } 217 | } 218 | 219 | if (!function_exists('get_json')) { 220 | /** 221 | * Get json input. 222 | * 223 | * @param string $key 224 | * @param bool $array 225 | * 226 | * @return array 227 | */ 228 | function get_json($key, $array = true) 229 | { 230 | return Tool::getJson($key, $array); 231 | } 232 | } 233 | 234 | if (!function_exists('is_empty')) { 235 | /** 236 | * Check object is empty. 237 | * 238 | * @param string $var 239 | * 240 | * @return bool 241 | */ 242 | function is_empty($var) 243 | { 244 | return (count($var) === 0) ? true : false; 245 | } 246 | } 247 | 248 | if (!function_exists('link_to_cms')) { 249 | /** 250 | * Link to cms route. 251 | * 252 | * @param string $var 253 | * @param string $fix 254 | * 255 | * @return bool 256 | */ 257 | function link_to_cms($link, $title, $attributes = [], $secure = null) 258 | { 259 | return link_to('cms/'.$link, $title, $attributes, $secure); 260 | } 261 | } 262 | 263 | if (!function_exists('selected')) { 264 | /** 265 | * Print out selected=selected if true. 266 | * 267 | * @param string $var 268 | * @param string $fix 269 | * 270 | * @return bool 271 | */ 272 | function selected($var, $fix) 273 | { 274 | return Tool::isSelected($var, $fix); 275 | } 276 | } 277 | 278 | if (!function_exists('system_role_class')) { 279 | /** 280 | * Print class if system role. 281 | * 282 | * @param int $level 283 | * @param string $class_yes 284 | * @param string $class_not 285 | * 286 | * @return string 287 | */ 288 | function system_role_class($level, $class_yes, $class_not) 289 | { 290 | return (LEVEL > $level) ? $class_yes : $class_not; 291 | } 292 | } 293 | -------------------------------------------------------------------------------- /app/molio/Validation/ContactForm.php: -------------------------------------------------------------------------------- 1 | 'required|min:10', 14 | 15 | 'number' => ['required', 'min:10', 'regex:/^\+[1-9]{1}[0-9]{7,11}$/'], 16 | 17 | ]; 18 | 19 | public function setUserId($userId) 20 | { 21 | $this->userId = $userId; 22 | $this->rules = [ 23 | 24 | //'number' =>'required|min:10', 25 | 26 | 'number' => ['required', 'min:10', 'regex:/^\+[1-9]{1}[0-9]{7,11}$/', 'unique:contacts,number,NULL,id,user_id,'.$this->userId], 27 | 28 | ]; 29 | } 30 | 31 | public function getUserId() 32 | { 33 | return $this->rules; 34 | } 35 | 36 | // 37 | } 38 | -------------------------------------------------------------------------------- /app/molio/Validation/ContactGroupForm.php: -------------------------------------------------------------------------------- 1 | 'required|min:2', 12 | 13 | ]; 14 | } 15 | -------------------------------------------------------------------------------- /app/molio/Validation/FavoriteForm.php: -------------------------------------------------------------------------------- 1 | 'required|min:2', 12 | 'address' => 'required|min:5', 13 | 'lat' => 'required', 14 | 'lng' => 'required', 15 | 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/molio/Validation/FavoriteUpdateForm.php: -------------------------------------------------------------------------------- 1 | 'required|min:2', 12 | 13 | ]; 14 | } 15 | -------------------------------------------------------------------------------- /app/molio/Validation/ImageUploadForm.php: -------------------------------------------------------------------------------- 1 | 'image|required', 12 | ]; 13 | } 14 | -------------------------------------------------------------------------------- /app/molio/Validation/LoginForm.php: -------------------------------------------------------------------------------- 1 | 'required', 12 | 'password' => 'required', 13 | ]; 14 | } 15 | -------------------------------------------------------------------------------- /app/molio/Validation/PasswordForm.php: -------------------------------------------------------------------------------- 1 | 'required|min:5', 11 | 'passwordmatch' => 'required|same:password', 12 | 13 | ]; 14 | } 15 | -------------------------------------------------------------------------------- /app/molio/Validation/RegistrationForm.php: -------------------------------------------------------------------------------- 1 | 'required|unique:users', 12 | 'email' => 'required|unique:users|email', 13 | 'password' => 'required', 14 | 'fname' => 'required|min:3|max:30', 15 | 'lname' => 'required|max:20', 16 | 'address' => 'required|min:10', 17 | ]; 18 | } 19 | -------------------------------------------------------------------------------- /app/molio/Validation/UpdateForm.php: -------------------------------------------------------------------------------- 1 | 'min:3|max:30', 12 | 'lname' => 'max:20', 13 | 'address' => 'min:10', 14 | 'email' => 'email', 15 | ]; 16 | } 17 | -------------------------------------------------------------------------------- /app/routes.php: -------------------------------------------------------------------------------- 1 | 'api'], function () { 24 | 25 | //register 26 | Route::post('user/register', 'UserController@register'); 27 | 28 | //login 29 | Route::post('user/login', 'UserController@login'); 30 | 31 | //logout 32 | Route::get('user/logout', 'UserController@logout'); 33 | 34 | //update user password 35 | Route::post('user/password/update', 'UserController@postUserPasswordUpdate'); 36 | 37 | //password reset 38 | Route::controller('user/password', 'RemindersController'); 39 | 40 | //show status 41 | Route::get('user/status', 'UserController@status'); 42 | 43 | //view update delete 44 | Route::resource('user', 'UserController', ['only' => ['show', 'update', 'destroy']]); 45 | 46 | //upload user image 47 | Route::post('user/profile/image', 'UserController@postUserImage'); 48 | 49 | //user phone number 50 | Route::put('user/mobilenumber/{userId}', 'UserController@mobileNumber'); 51 | 52 | //favorite count 53 | Route::get('favorites/count', 'FavoriteController@count'); 54 | 55 | //favorite 56 | Route::resource('favorites', 'FavoriteController', ['only'=>['index', 'store', 'update', 'destroy']]); 57 | 58 | //contact 59 | Route::get('/contacts', 'ContactController@contactIndex'); 60 | 61 | //contacts route group 62 | Route::group(['prefix' => 'contacts'], function () { 63 | 64 | //groups 65 | Route::resource('groups', 'ContactController'); 66 | 67 | //list contacts 68 | Route::get('groups/{groups}/links', 'ContactController@getContact'); 69 | 70 | //create contact 71 | Route::post('groups/{groups}/links', 'ContactController@postContact'); 72 | 73 | //delete contact 74 | Route::delete('groups/{groups}/links', 'ContactController@deleteContact'); 75 | }); 76 | }); 77 | -------------------------------------------------------------------------------- /app/start/artisan.php: -------------------------------------------------------------------------------- 1 | array('message'=>'Invalid Parameters')), 401); 59 | });*/ 60 | 61 | App::error(function (Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException $exception) { 62 | return Response::json(['error' => ['message' => 'This service is Unavailable !', 'status_code' =>'403']], 403); 63 | }); 64 | 65 | App::error(function (\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $exception) { 66 | return Response::json(['error' => ['message' => 'This service is Unavailable !', 'status_code' =>'403']], 403); 67 | }); 68 | 69 | /* 70 | |-------------------------------------------------------------------------- 71 | | Maintenance Mode Handler 72 | |-------------------------------------------------------------------------- 73 | | 74 | | The "down" Artisan command gives you the ability to put an application 75 | | into maintenance mode. Here, you will define what is displayed back 76 | | to the user if maintenance mode is in effect for the application. 77 | | 78 | */ 79 | 80 | App::down(function () { 81 | return Response::make('Be right back!', 503); 82 | }); 83 | 84 | /* 85 | |-------------------------------------------------------------------------- 86 | | Require The Filters File 87 | |-------------------------------------------------------------------------- 88 | | 89 | | Next we will load the filters file for the application. This gives us 90 | | a nice separate location to store our route and application filter 91 | | definitions instead of putting them all in the main routes file. 92 | | 93 | */ 94 | 95 | require app_path().'/filters.php'; 96 | -------------------------------------------------------------------------------- /app/start/local.php: -------------------------------------------------------------------------------- 1 | fake = Faker::create(); 24 | $this->statFavitems = [ 25 | 26 | 'name' => 'this is a test data', 27 | 'address' => 'this is a test data', 28 | 'lat' => '18.920882', 29 | 'lng' => '72.897720', 30 | 31 | ]; 32 | 33 | $this->contacts['numbers'] = ['+49162921322', '+49162921325', '+49162926397', '+49162928673', '+49162926548']; 34 | 35 | $this->group = ['name' => 'test Group']; 36 | } 37 | 38 | /** 39 | * setting up testing enviorment. 40 | */ 41 | public function setUp() 42 | { 43 | parent::setUp(); 44 | 45 | $this->app['artisan']->call('migrate'); 46 | 47 | Route::enableFilters(); 48 | } 49 | 50 | public static function tearDownAfterClass() 51 | { 52 | Artisan::call('migrate:reset'); 53 | } 54 | 55 | public function CreateUserFakerData($userFields = []) 56 | { 57 | $user = array_merge([ 58 | 59 | 'username' => $this->fake->username, 60 | 'password' => $this->fake->name, 61 | 'email' => $this->fake->email, 62 | 'fname' => $this->fake->firstName, 63 | 'lname' => $this->fake->lastName, 64 | 'address' => $this->fake->address, 65 | 66 | ], $userFields); 67 | 68 | return $user; 69 | } 70 | 71 | public function getUserInvalidLoginData($userFields = []) 72 | { 73 | $user = array_merge([ 74 | 75 | 'username' => $this->fake->username, 76 | 'password' => $this->fake->name, 77 | 78 | ], $userFields); 79 | 80 | return $user; 81 | } 82 | 83 | public function getUserValidLoginData($user) 84 | { 85 | return ['username' =>$user['username'], 'password'=>$user['password']]; 86 | } 87 | 88 | public function sendRestPasswordRequest() 89 | { 90 | } 91 | 92 | public function getJson($uri, $user = []) 93 | { 94 | if (empty($user)) { 95 | return json_decode($this->call('GET', $uri)->getContent()); 96 | } else { 97 | return json_decode($this->call('GET', $uri, $user)->getContent()); 98 | } 99 | } 100 | 101 | public function postJson($uri, $user = []) 102 | { 103 | return json_decode($this->call('POST', $uri, $user)->getContent()); 104 | } 105 | 106 | public function fileJson($uri, $user = []) 107 | { 108 | return json_decode($this->call('FILE', $uri, $user)->getContent()); 109 | } 110 | 111 | public function putJson($uri, $user = []) 112 | { 113 | return json_decode($this->call('PUT', $uri, $user)->getContent()); 114 | } 115 | 116 | public function deleteJson($uri, $user = []) 117 | { 118 | return json_decode($this->call('DELETE', $uri, $user)->getContent()); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /app/tests/ContactTest.php: -------------------------------------------------------------------------------- 1 | createUserFakerData(); 15 | 16 | //action 17 | $return = $this->postJson('api/user/register', $user)->message; 18 | 19 | //assert 20 | $this->assertEquals('Successfully Registered !', $return); 21 | $this->assertResponseOk(); 22 | 23 | return Auth::user(); 24 | } 25 | 26 | /** 27 | * Testing Group create. 28 | * 29 | * @depends testInitUser 30 | * 31 | * @return object 32 | */ 33 | public function testGroupCreate($user) 34 | { 35 | 36 | //arrange 37 | $this->be($user); 38 | 39 | //action 40 | $return = $this->postJson('api/contacts/groups', $this->group)->message; 41 | 42 | //assert 43 | $this->assertEquals('Successfully Created New Group !', $return); 44 | $this->assertResponseOk(); 45 | 46 | return Auth::user(); 47 | } 48 | 49 | /** 50 | * Testing contact group display. 51 | * 52 | * @depends testGroupCreate 53 | * 54 | * @return object 55 | */ 56 | public function testgetGroups($user) 57 | { 58 | 59 | //arrange 60 | $this->be($user); 61 | 62 | //action 63 | $return = $this->getJson('api/contacts/groups'); 64 | 65 | //assert 66 | $this->assertEquals($this->group['name'], $return->data[0]->Name); 67 | $this->assertResponseOk(); 68 | 69 | return Auth::user(); 70 | } 71 | 72 | /** 73 | * Testing Group data update. 74 | * 75 | * @depends testGroupCreate 76 | * 77 | * @return object 78 | */ 79 | public function testGroupDataUpdate($user) 80 | { 81 | 82 | //arrange 83 | $this->be($user); 84 | $grpid = Group::where('name', '=', $this->group['name'])->first()->id; 85 | $this->group['name'] = 'Updated Name'; 86 | 87 | //action 88 | $return = $this->putJson('api/contacts/groups/'.$grpid, $this->group)->message; 89 | 90 | $updatedName = Group::where('name', '=', $this->group['name'])->first()->name; 91 | 92 | //assert 93 | $this->assertEquals($this->group['name'], $updatedName); 94 | $this->assertEquals('Successfully Updated Group !', $return); 95 | 96 | $this->assertResponseOk(); 97 | 98 | return Auth::user(); 99 | } 100 | 101 | /** 102 | * Testing Create new Contact datas. 103 | * 104 | * @depends testGroupDataUpdate 105 | * 106 | * @return object 107 | */ 108 | public function testContactsCreate($user) 109 | { 110 | $datas = $this->contacts; 111 | 112 | //arrange 113 | $this->be($user); 114 | $this->group['name'] = 'Updated Name'; 115 | $grpid = Group::where('name', '=', $this->group['name'])->first()->id; 116 | 117 | //action 118 | $return = $this->postJson('api/contacts/groups/'.$grpid.'/links', $datas)->message; 119 | 120 | //assert 121 | $this->assertEquals('Successfully Added Contacts !', $return); 122 | 123 | $this->assertResponseOk(); 124 | 125 | return Auth::user(); 126 | } 127 | 128 | /** 129 | * Testing Create new Contact datas. 130 | * 131 | * @depends testContactsCreate 132 | * 133 | * @return object 134 | */ 135 | public function testSearchContacts($user) 136 | { 137 | $datas = $this->contacts; 138 | 139 | $datas[] = ['+49161234567']; 140 | //arrange 141 | $this->be($user); 142 | 143 | //action 144 | $return = (array) $this->postJson('api/contacts/', $datas)->data; 145 | 146 | $resultArray = []; 147 | foreach ($return as $value) { 148 | $resultArray[] = $value->Number; 149 | } 150 | 151 | if (count(array_diff($resultArray, $this->contacts['numbers'])) == 0) { 152 | $return = 'Fine'; 153 | } else { 154 | $return = 'Faild'; 155 | } 156 | //assert 157 | $this->assertEquals('Fine', $return); 158 | 159 | $this->assertResponseOk(); 160 | 161 | return Auth::user(); 162 | } 163 | 164 | /** 165 | * Testing display contact datas under a group. 166 | * 167 | * @depends testContactsCreate 168 | * 169 | * @return object 170 | */ 171 | public function testContactsDisplay($user) 172 | { 173 | $datas = $this->contacts; 174 | 175 | //arrange 176 | $this->be($user); 177 | $this->group['name'] = 'Updated Name'; 178 | $grpid = Group::where('name', '=', $this->group['name'])->first()->id; 179 | 180 | //action 181 | $return = $this->getJson('api/contacts/groups/'.$grpid.'/links', $datas); 182 | 183 | //assert 184 | $this->assertResponseOk(); 185 | 186 | return Auth::user(); 187 | } 188 | 189 | /** 190 | * Testing delteting multiple contacts. 191 | * 192 | * @depends testContactsCreate 193 | * 194 | * @return object 195 | */ 196 | public function testContactsDelete($user) 197 | { 198 | $datas['numbers'] = [$this->contacts['numbers'][1], $this->contacts['numbers'][3]]; 199 | 200 | //arrange 201 | $this->be($user); 202 | 203 | $this->group['name'] = 'Updated Name'; 204 | $grpid = Group::where('name', '=', $this->group['name'])->first()->id; 205 | //dd($user->id.":::".$grpid); 206 | 207 | //action 208 | $return = $this->deleteJson('api/contacts/groups/'.$grpid.'/links', $datas)->message; 209 | //dd($return); 210 | 211 | $this->assertEquals('Successfully Deleted Contacts !', $return); 212 | 213 | //assert 214 | $this->assertResponseOk(); 215 | 216 | return Auth::user(); 217 | } 218 | 219 | /** 220 | * Testing Group item delete. 221 | * 222 | * @depends testContactsDelete 223 | * 224 | * @return object 225 | */ 226 | public function testGroupDelete($user) 227 | { 228 | 229 | //arrange 230 | $this->be($user); 231 | $this->group['name'] = 'Updated Name'; 232 | $grpid = Group::where('name', '=', $this->group['name'])->first()->id; 233 | 234 | //action 235 | $return = $this->deleteJson('api/contacts/groups/'.$grpid)->message; 236 | 237 | //assert 238 | $this->assertEquals('Successfully deleted the group !', $return); 239 | 240 | $this->assertResponseOk(); 241 | 242 | return Auth::user(); 243 | } 244 | } 245 | -------------------------------------------------------------------------------- /app/tests/FavoriteItemTest.php: -------------------------------------------------------------------------------- 1 | createUserFakerData(); 16 | 17 | //action 18 | $return = $this->postJson('api/user/register', $user)->message; 19 | 20 | //assert 21 | $this->assertEquals('Successfully Registered !', $return); 22 | $this->assertResponseOk(); 23 | 24 | return Auth::user(); 25 | } 26 | 27 | /** 28 | * Testing Favorite item data create. 29 | * 30 | * @depends testInitUser 31 | * 32 | * @return object 33 | */ 34 | public function testFavoriteItemCreate($user) 35 | { 36 | 37 | //arrange 38 | $this->be($user); 39 | 40 | //action 41 | $return = $this->postJson('api/favorites', $this->statFavitems)->message; 42 | 43 | //assert 44 | $this->assertEquals('Successfully Created Favorite Item !', $return); 45 | $this->assertResponseOk(); 46 | 47 | return Auth::user(); 48 | } 49 | 50 | /** 51 | * Testing Favorite item data display. 52 | * 53 | * @depends testFavoriteItemCreate 54 | * 55 | * @return object 56 | */ 57 | public function testFavoriteItemDisplay($user) 58 | { 59 | 60 | //arrange 61 | $this->be($user); 62 | 63 | //action 64 | $return = $this->getJson('api/favorites', $this->statFavitems); 65 | 66 | //assert 67 | $this->assertEquals($this->statFavitems['name'], $return->data[0]->Name); 68 | $this->assertEquals($this->statFavitems['address'], $return->data[0]->Address); 69 | $this->assertEquals($this->statFavitems['lat'], $return->data[0]->Latitude); 70 | $this->assertEquals($this->statFavitems['lng'], $return->data[0]->Longitude); 71 | $this->assertResponseOk(); 72 | 73 | return Auth::user(); 74 | } 75 | 76 | /** 77 | * Testing Favorite item data update. 78 | * 79 | * @depends testFavoriteItemCreate 80 | * 81 | * @return object 82 | */ 83 | public function testFavoriteItemUpdate($user) 84 | { 85 | 86 | //arrange 87 | $this->be($user); 88 | $favid = Favorite::where('name', '=', $this->statFavitems['name'])->first()->id; 89 | $this->statFavitems['name'] = 'Updated Name'; 90 | 91 | //action 92 | $return = $this->putJson('api/favorites/'.$favid, $this->statFavitems)->message; 93 | 94 | $updatedName = Favorite::where('name', '=', $this->statFavitems['name'])->first()->name; 95 | 96 | //assert 97 | $this->assertEquals($this->statFavitems['name'], $updatedName); 98 | $this->assertEquals('Successfully Updated favorite item !', $return); 99 | 100 | $this->assertResponseOk(); 101 | 102 | return Auth::user(); 103 | } 104 | 105 | /** 106 | * Testing Favorite item data delete. 107 | * 108 | * @depends testFavoriteItemUpdate 109 | * 110 | * @return object 111 | */ 112 | public function testFavoriteItemDelete($user) 113 | { 114 | 115 | //arrange 116 | $this->be($user); 117 | $this->statFavitems['name'] = 'Updated Name'; 118 | $favid = Favorite::where('name', '=', $this->statFavitems['name'])->first()->id; 119 | 120 | //action 121 | $return = $this->deleteJson('api/favorites/'.$favid)->message; 122 | 123 | //assert 124 | $this->assertEquals('Successfully Deleted favorite item !', $return); 125 | 126 | $this->assertResponseOk(); 127 | 128 | return Auth::user(); 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /app/tests/TestCase.php: -------------------------------------------------------------------------------- 1 | createUserFakerData(); 15 | 16 | //action 17 | $return = $this->postJson('api/user/register', $user)->message; 18 | 19 | //assert 20 | $this->assertEquals('Successfully Registered !', $return); 21 | $this->assertResponseOk(); 22 | 23 | return $user; 24 | } 25 | 26 | /** 27 | * Testing User Login with Valid Credentials. 28 | * 29 | * @depends testUserCreate 30 | * 31 | * @return void 32 | */ 33 | public function testUserLoginWithValidCredential($user) 34 | { 35 | 36 | //arrange 37 | $userLogin = $this->getUserValidLoginData($user); 38 | 39 | //action 40 | $return = $this->postJson('api/user/login', $userLogin)->message; 41 | 42 | //assert 43 | $this->assertEquals('Successfully Logged In !', $return); 44 | $this->assertResponseOk(); 45 | 46 | return Auth::user(); 47 | } 48 | 49 | /** 50 | * Testing User Login with Invalid Credentials. 51 | * 52 | * @return void 53 | */ 54 | public function testUserLoginWithInValidCredential() 55 | { 56 | //arrange 57 | $user = $this->getUserInvalidLoginData(); 58 | 59 | //action 60 | $return = $this->postJson('api/user/login', $user)->error; 61 | 62 | //assert 63 | $this->assertEquals('Enter valid credentials !', $return->message[0]); 64 | $this->assertResponseStatus(403); 65 | } 66 | 67 | /** 68 | * Testing User Page with Invalid Credentials. 69 | * 70 | * @return void 71 | */ 72 | public function testNonPrivilagedPages() 73 | { 74 | //action 75 | $return = $this->getJson('api/user/status')->error; 76 | 77 | //assert 78 | $this->assertEquals('Invalid Credentials', $return->message); 79 | $this->assertResponseStatus(401); 80 | } 81 | 82 | /** 83 | * Testing User status. 84 | * 85 | * @depends testUserLoginWithValidCredential 86 | */ 87 | public function testgetStatus($user) 88 | { 89 | 90 | //arrange 91 | $this->be($user); 92 | 93 | //action 94 | $return = $this->getJson('api/user/status'); 95 | 96 | //assert 97 | $this->assertEquals('Active', $return->status); 98 | $this->assertResponseOk(); 99 | } 100 | 101 | /** 102 | * Test user update. 103 | * 104 | * @depends testUserLoginWithValidCredential 105 | */ 106 | public function testUpadteUser($user) 107 | { 108 | 109 | //arrange 110 | $this->be($user); 111 | 112 | $newdata = $this->CreateUserFakerData(); 113 | 114 | //action 115 | $return = $this->putJson('api/user/update', $newdata)->message; 116 | 117 | //assert 118 | $this->assertEquals('Profile Updated successfully !', $return); 119 | $this->assertResponseOk(); 120 | } 121 | 122 | /** 123 | * Test user information. 124 | * 125 | * @depends testUserLoginWithValidCredential 126 | */ 127 | public function testGetUserData($user) 128 | { 129 | //arrange 130 | $this->be($user); 131 | 132 | //action 133 | $return = (array) $this->getJson('api/user/data'); 134 | $datamaper = new molio\ApiDataMapper\UserDataMapper(); 135 | $result = json_encode($datamaper->mapper($user->toArray())); 136 | 137 | //assert 138 | $this->assertEquals($result, json_encode($return)); 139 | $this->assertResponseOk(); 140 | } 141 | 142 | /** 143 | * Test create userphone number. 144 | * 145 | * @depends testUserLoginWithValidCredential 146 | */ 147 | public function testCreateUserPhone($user) 148 | { 149 | $this->be($user); 150 | 151 | $data['phone_number'] = $this->contacts['numbers'][0]; 152 | 153 | //action 154 | $return = $this->putJson('api/user/mobilenumber/'.$user->id, $data)->message; 155 | 156 | //assert 157 | $this->assertEquals('Successfully updated phone number !', $return); 158 | $this->assertResponseOk(); 159 | } 160 | 161 | /** 162 | * Test user dissable account. 163 | * 164 | * @depends testUserLoginWithValidCredential 165 | */ 166 | public function testDissable($user) 167 | { 168 | 169 | //arrange 170 | $this->be($user); 171 | 172 | //action 173 | $return = $this->deleteJson('api/user/'.$user->id)->message; 174 | 175 | //assert 176 | $this->assertEquals('Successfully Disabled Account !', $return); 177 | $this->assertResponseOk(); 178 | } 179 | 180 | /** 181 | * Test user logout account. 182 | * 183 | * @depends testUserLoginWithValidCredential 184 | */ 185 | public function testUserLogout($user) 186 | { 187 | 188 | //arrange 189 | $this->be($user); 190 | 191 | //action 192 | $return = $this->getJson('api/user/logout')->message; 193 | 194 | //assert 195 | $this->assertEquals('Successfully Logged Out !', $return); 196 | $this->assertResponseOk(); 197 | } 198 | 199 | /** 200 | * Test user to reset password. 201 | * 202 | * @return object 203 | */ 204 | public function testSendResetPasswordTocken() 205 | { 206 | 207 | //arrange 208 | $user = User::create(['username' => 'fasil', 'fname' => 'teste l name', 'lname' => 'brown', 'email' => 'kk.fasil@yahoo.com', 'address' => 'test address', 'password' => 'mysecretpass']); 209 | $this->be($user); 210 | 211 | $data = ['email' => $user->email]; 212 | 213 | //action 214 | $return = $this->postJson('api/user/password/remind', $data)->message; 215 | 216 | //assert 217 | $this->assertEquals('password token sent successfully to your email !', $return); 218 | $this->assertResponseOk(); 219 | 220 | return $user; 221 | } 222 | 223 | /** 224 | * Test user to reset password. 225 | * 226 | * @depends testSendResetPasswordTocken 227 | */ 228 | public function testVerifyPasswordResetToken($user) 229 | { 230 | //arrange 231 | $this->be($user); 232 | 233 | $token = DB::table(Config::get('auth.reminder.table'))->where('email', Auth::user()->email)->pluck('token'); 234 | 235 | $data = ['email' => Auth::user()->email, 'password' => 'resetpass', 'password_confirmation' => 'resetpass', 'token' => $token]; 236 | 237 | //action 238 | $return = $this->postJson('api/user/password/reset', $data)->message; 239 | 240 | //assert 241 | $this->assertEquals('Password Reset Succesfully !', $return); 242 | 243 | $this->assertResponseOk(); 244 | } 245 | 246 | /** 247 | * Test for user update password after logged in. 248 | * 249 | * @depends testUserLoginWithValidCredential 250 | */ 251 | public function testUserPasswordUpdate($user) 252 | { 253 | 254 | //arrange 255 | $this->be($user); 256 | 257 | $input = ['password' => 'newpass##', 'passwordmatch' => 'newpass##']; 258 | 259 | //action 260 | $return = $this->postJson('api/user/password/update', $input)->message; 261 | 262 | //assert 263 | $this->assertEquals('Password Updated successfully !', $return); 264 | $this->assertResponseOk(); 265 | } 266 | } 267 | -------------------------------------------------------------------------------- /app/views/emails/auth/reminder.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Password Reset

8 | 9 |
10 | To reset your password, complete this form: {{ URL::to('password/reset', array($token)) }}.
11 | This link will expire in {{ Config::get('auth.reminder.expire', 60) }} minutes. 12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /app/views/hello.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Laravel PHP Framework 6 | 35 | 36 | 37 |
38 | Laravel PHP Framework 39 |

You have arrived.

40 |
41 | 42 | 43 | -------------------------------------------------------------------------------- /artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | setRequestForConsoleEnvironment(); 45 | 46 | $artisan = Illuminate\Console\Application::start($app); 47 | 48 | /* 49 | |-------------------------------------------------------------------------- 50 | | Run The Artisan Application 51 | |-------------------------------------------------------------------------- 52 | | 53 | | When we run the console application, the current CLI command will be 54 | | executed in this console and the response sent back to a terminal 55 | | or another output device for the developers. Here goes nothing! 56 | | 57 | */ 58 | 59 | $status = $artisan->run(); 60 | 61 | /* 62 | |-------------------------------------------------------------------------- 63 | | Shutdown The Application 64 | |-------------------------------------------------------------------------- 65 | | 66 | | Once Artisan has finished running. We will fire off the shutdown events 67 | | so that any final work may be done by the application before we shut 68 | | down the process. This is the last thing to happen to the request. 69 | | 70 | */ 71 | 72 | $app->shutdown(); 73 | 74 | exit($status); 75 | -------------------------------------------------------------------------------- /bootstrap/autoload.php: -------------------------------------------------------------------------------- 1 | __DIR__.'/../app', 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Public Path 21 | |-------------------------------------------------------------------------- 22 | | 23 | | The public path contains the assets for your web application, such as 24 | | your JavaScript and CSS files, and also contains the primary entry 25 | | point for web requests into these applications from the outside. 26 | | 27 | */ 28 | 29 | 'public' => __DIR__.'/../public', 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Base Path 34 | |-------------------------------------------------------------------------- 35 | | 36 | | The base path is the root of the Laravel installation. Most likely you 37 | | will not need to change this value. But, if for some wild reason it 38 | | is necessary you will do so here, just proceed with some caution. 39 | | 40 | */ 41 | 42 | 'base' => __DIR__.'/..', 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Storage Path 47 | |-------------------------------------------------------------------------- 48 | | 49 | | The storage path is used by Laravel to store cached Blade views, logs 50 | | and other pieces of information. You may modify the path here when 51 | | you want to change the location of this directory for your apps. 52 | | 53 | */ 54 | 55 | 'storage' => __DIR__.'/../app/storage', 56 | 57 | ]; 58 | -------------------------------------------------------------------------------- /bootstrap/start.php: -------------------------------------------------------------------------------- 1 | detectEnvironment([ 28 | 29 | 'local' => ['0xSREEJ32H', 'Fasil'], 30 | 'stage' => ['amuniola'], 31 | ]); 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | Bind Paths 36 | |-------------------------------------------------------------------------- 37 | | 38 | | Here we are binding the paths configured in paths.php to the app. You 39 | | should not be changing these here. If you need to change these you 40 | | may do so within the paths.php file and they will be bound here. 41 | | 42 | */ 43 | 44 | $app->bindInstallPaths(require __DIR__.'/paths.php'); 45 | 46 | /* 47 | |-------------------------------------------------------------------------- 48 | | Load The Application 49 | |-------------------------------------------------------------------------- 50 | | 51 | | Here we will load this Illuminate application. We will keep this in a 52 | | separate location so we can isolate the creation of an application 53 | | from the actual running of the application with a given request. 54 | | 55 | */ 56 | 57 | $framework = $app['path.base']. 58 | '/vendor/laravel/framework/src'; 59 | 60 | require $framework.'/Illuminate/Foundation/start.php'; 61 | 62 | /* 63 | |-------------------------------------------------------------------------- 64 | | Return The Application 65 | |-------------------------------------------------------------------------- 66 | | 67 | | This script returns the application instance. The instance is given to 68 | | the calling script so we can separate the building of the instances 69 | | from the actual running of the application and sending responses. 70 | | 71 | */ 72 | 73 | return $app; 74 | -------------------------------------------------------------------------------- /build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 10 | 11 | 13 | 14 | 16 | 17 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | Cleaning out the build artifacts 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | Cleaning out the composer artifacts 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | Installing dependencies 67 | 68 | 69 | 70 | 71 | 72 | 73 | Updating dependencies 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | Setting app/storage to 777 180 | 181 | 182 | 183 | 184 | Setting app/storage to writable 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | Making the build artifact folders 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | -------------------------------------------------------------------------------- /build/phpcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Description of your coding standard 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /build/phpdox.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /build/phpmd.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | Description of your coding standard 11 | 12 | 13 | 14 | 15 | 23 | 24 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "description": "The Laravel Framework.", 4 | "keywords": ["framework", "laravel"], 5 | "license": "MIT", 6 | "type": "project", 7 | "require": { 8 | "laravel/framework": "4.2.*" 9 | 10 | }, 11 | "require-dev":{ 12 | "way/generators": "~2.0", 13 | "laracasts/validation": "~1.0", 14 | "fzaninotto/faker": "~1.4" 15 | }, 16 | "autoload": { 17 | "classmap": [ 18 | "app/commands", 19 | "app/controllers", 20 | "app/models", 21 | "app/database/migrations", 22 | "app/database/seeds", 23 | "app/tests/TestCase.php", 24 | "app/molio", 25 | "app/tests/ApiTester.php" 26 | ] 27 | }, 28 | "psr-4":{ 29 | "molio\\" : "app/molio" 30 | 31 | }, 32 | "scripts": { 33 | "post-install-cmd": [ 34 | "php artisan clear-compiled", 35 | "php artisan optimize" 36 | ], 37 | "post-update-cmd": [ 38 | "php artisan clear-compiled", 39 | "php artisan optimize" 40 | ], 41 | "post-create-project-cmd": [ 42 | "php artisan key:generate" 43 | ] 44 | }, 45 | "config": { 46 | "preferred-install": "dist" 47 | }, 48 | "minimum-stability": "stable" 49 | } 50 | -------------------------------------------------------------------------------- /deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # ---------------------- 4 | # KUDU Deployment Script 5 | # Version: 0.1.11 6 | # ---------------------- 7 | 8 | # Helpers 9 | # ------- 10 | 11 | exitWithMessageOnError () { 12 | if [ ! $? -eq 0 ]; then 13 | echo "An error has occurred during web site deployment." 14 | echo $1 15 | exit 1 16 | fi 17 | } 18 | 19 | # Prerequisites 20 | # ------------- 21 | 22 | # Verify node.js installed 23 | hash node 2>/dev/null 24 | exitWithMessageOnError "Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment." 25 | 26 | # Setup 27 | # ----- 28 | 29 | SCRIPT_DIR="${BASH_SOURCE[0]%\\*}" 30 | SCRIPT_DIR="${SCRIPT_DIR%/*}" 31 | ARTIFACTS=$SCRIPT_DIR/../artifacts 32 | KUDU_SYNC_CMD=${KUDU_SYNC_CMD//\"} 33 | 34 | if [[ ! -n "$DEPLOYMENT_SOURCE" ]]; then 35 | DEPLOYMENT_SOURCE=$SCRIPT_DIR 36 | fi 37 | 38 | if [[ ! -n "$NEXT_MANIFEST_PATH" ]]; then 39 | NEXT_MANIFEST_PATH=$ARTIFACTS/manifest 40 | 41 | if [[ ! -n "$PREVIOUS_MANIFEST_PATH" ]]; then 42 | PREVIOUS_MANIFEST_PATH=$NEXT_MANIFEST_PATH 43 | fi 44 | fi 45 | 46 | if [[ ! -n "$DEPLOYMENT_TARGET" ]]; then 47 | DEPLOYMENT_TARGET=$ARTIFACTS/wwwroot 48 | else 49 | KUDU_SERVICE=true 50 | fi 51 | 52 | if [[ ! -n "$KUDU_SYNC_CMD" ]]; then 53 | # Install kudu sync 54 | echo Installing Kudu Sync 55 | npm install kudusync -g --silent 56 | exitWithMessageOnError "npm failed" 57 | 58 | if [[ ! -n "$KUDU_SERVICE" ]]; then 59 | # In case we are running locally this is the correct location of kuduSync 60 | KUDU_SYNC_CMD=kuduSync 61 | else 62 | # In case we are running on kudu service this is the correct location of kuduSync 63 | KUDU_SYNC_CMD=$APPDATA/npm/node_modules/kuduSync/bin/kuduSync 64 | fi 65 | fi 66 | 67 | ################################################################################################################################## 68 | # Download Composer 69 | # ---------- 70 | echo Downloading Composer 71 | curl -sS https://getcomposer.org/installer | php 72 | 73 | ################################################################################################################################## 74 | # Deployment 75 | # ---------- 76 | 77 | echo Handling Basic Web Site deployment. 78 | 79 | # 1. KuduSync 80 | if [[ "$IN_PLACE_DEPLOYMENT" -ne "1" ]]; then 81 | "$KUDU_SYNC_CMD" -v 50 -f "$DEPLOYMENT_SOURCE" -t "$DEPLOYMENT_TARGET" -n "$NEXT_MANIFEST_PATH" -p "$PREVIOUS_MANIFEST_PATH" -i ".git;.hg;.deployment;deploy.sh" 82 | exitWithMessageOnError "Kudu Sync failed" 83 | fi 84 | 85 | ################################################################################################################################## 86 | # Dependency install 87 | # ---------- 88 | 89 | # Invoke Composer in the deployment directory 90 | echo Invoking composer install in deployment directory $DEPLOYMENT_TARGET 91 | php -d extension=php_intl.dll $DEPLOYMENT_TARGET/composer.phar install -v --prefer-dist --no-dev --optimize-autoloader --no-interaction 92 | 93 | ################################################################################################################################## 94 | 95 | # Post deployment stub 96 | if [[ -n "$POST_DEPLOYMENT_ACTION" ]]; then 97 | POST_DEPLOYMENT_ACTION=${POST_DEPLOYMENT_ACTION//\"} 98 | cd "${POST_DEPLOYMENT_ACTION_DIR%\\*}" 99 | "$POST_DEPLOYMENT_ACTION" 100 | exitWithMessageOnError "post deployment action failed" 101 | fi 102 | 103 | echo "Finished successfully." -------------------------------------------------------------------------------- /deploy.sh~: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fasilkk/SampleRestAPI/9080ffddc9414bb0cdc673918f79ea6ac0a4d70b/deploy.sh~ -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | ./app/tests/ 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | ./app/tests/ 16 | 17 | 18 | 19 | 20 | ./app/ 21 | 22 | 23 | 24 | 27 | 28 | 30 | 31 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Redirect Trailing Slashes... 9 | RewriteRule ^(.*)/$ /$1 [L,R=301] 10 | 11 | # Handle Front Controller... 12 | RewriteCond %{REQUEST_FILENAME} !-d 13 | RewriteCond %{REQUEST_FILENAME} !-f 14 | RewriteRule ^ index.php [L] 15 | 16 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fasilkk/SampleRestAPI/9080ffddc9414bb0cdc673918f79ea6ac0a4d70b/public/favicon.ico -------------------------------------------------------------------------------- /public/img/usr_sreej32h.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fasilkk/SampleRestAPI/9080ffddc9414bb0cdc673918f79ea6ac0a4d70b/public/img/usr_sreej32h.jpg -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | 8 | /* 9 | |-------------------------------------------------------------------------- 10 | | Register The Auto Loader 11 | |-------------------------------------------------------------------------- 12 | | 13 | | Composer provides a convenient, automatically generated class loader 14 | | for our application. We just need to utilize it! We'll require it 15 | | into the script here so that we do not have to worry about the 16 | | loading of any our classes "manually". Feels great to relax. 17 | | 18 | */ 19 | 20 | require __DIR__.'/../bootstrap/autoload.php'; 21 | 22 | /* 23 | |-------------------------------------------------------------------------- 24 | | Turn On The Lights 25 | |-------------------------------------------------------------------------- 26 | | 27 | | We need to illuminate PHP development, so let's turn on the lights. 28 | | This bootstraps the framework and gets it ready for use, then it 29 | | will load up this application so that we can run it and send 30 | | the responses back to the browser and delight these users. 31 | | 32 | */ 33 | 34 | $app = require_once __DIR__.'/../bootstrap/start.php'; 35 | 36 | /* 37 | |-------------------------------------------------------------------------- 38 | | Run The Application 39 | |-------------------------------------------------------------------------- 40 | | 41 | | Once we have the application, we can simply call the run method, 42 | | which will execute the request and send the response back to 43 | | the client's browser allowing them to enjoy the creative 44 | | and wonderful application we have whipped up for them. 45 | | 46 | */ 47 | 48 | $app->run(); 49 | -------------------------------------------------------------------------------- /public/packages/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fasilkk/SampleRestAPI/9080ffddc9414bb0cdc673918f79ea6ac0a4d70b/public/packages/.gitkeep -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /server.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | - 5 | - 6 | - 7 | - 8 | - 9 | - 10 | - 11 | - 12 | - 13 | - 14 | - 15 | + 16 | + 17 | + 18 | + 19 | + 20 | + 21 | + 22 | + 23 | + 24 | + 25 | + 26 | + 27 | + 28 | + 29 | + 30 | + 31 | + 32 | + 33 | + 34 | --------------------------------------------------------------------------------