├── .env.example
├── .gitattributes
├── .gitignore
├── README.md
├── app
├── Console
│ └── Kernel.php
├── Exceptions
│ └── Handler.php
├── Http
│ ├── Controllers
│ │ ├── Api
│ │ │ ├── AuthorBookController.php
│ │ │ ├── AuthorController.php
│ │ │ ├── BookController.php
│ │ │ ├── LanguageBookController.php
│ │ │ ├── LanguagesController.php
│ │ │ ├── SwaggerController.php
│ │ │ └── UsersController.php
│ │ ├── Auth
│ │ │ ├── ForgotPasswordController.php
│ │ │ ├── LoginController.php
│ │ │ ├── RegisterController.php
│ │ │ └── ResetPasswordController.php
│ │ └── Controller.php
│ ├── Kernel.php
│ └── Middleware
│ │ ├── EncryptCookies.php
│ │ ├── RedirectIfAuthenticated.php
│ │ ├── TrimStrings.php
│ │ └── VerifyCsrfToken.php
├── Models
│ ├── Author.php
│ ├── Book.php
│ ├── Languages.php
│ └── Users.php
├── Providers
│ ├── AppServiceProvider.php
│ ├── AuthServiceProvider.php
│ ├── BroadcastServiceProvider.php
│ ├── EventServiceProvider.php
│ └── RouteServiceProvider.php
└── Transformer
│ ├── AuthorBookTransformer.php
│ ├── AuthorTransformer.php
│ ├── BookTransformer.php
│ ├── LanguagesTransformer.php
│ └── UsersTransformer.php
├── artisan
├── bootstrap
├── app.php
├── autoload.php
└── cache
│ └── .gitignore
├── composer.json
├── composer.lock
├── config
├── api.php
├── app.php
├── auth.php
├── broadcasting.php
├── cache.php
├── database.php
├── filesystems.php
├── l5-swagger.php
├── mail.php
├── queue.php
├── services.php
├── session.php
├── sluggable.php
└── view.php
├── database
├── .gitignore
├── factories
│ └── ModelFactory.php
├── migrations
│ ├── 2014_10_12_000000_create_users_table.php
│ ├── 2014_10_12_100000_create_password_resets_table.php
│ ├── 2017_07_01_203612_create_author_table.php
│ ├── 2017_07_01_203655_create_languages_table.php
│ └── 2017_07_01_203719_create_book_table.php
└── seeds
│ ├── AuthorTableSeeder.php
│ ├── BookTableSeeder.php
│ ├── DatabaseSeeder.php
│ ├── Languages.sql
│ ├── LanguagesTableSeeder.php
│ └── UsersTableSeeder.php
├── nbproject
├── project.properties
└── project.xml
├── package.json
├── phpunit.xml
├── public
├── .htaccess
├── css
│ └── app.css
├── favicon.ico
├── images
│ ├── angular.png
│ ├── angularjs.png
│ ├── composer.jpg
│ └── react.png
├── index.php
├── js
│ └── app.js
├── robots.txt
├── vendor
│ └── l5-swagger
│ │ ├── css
│ │ ├── print.css
│ │ ├── reset.css
│ │ ├── screen.css
│ │ ├── style.css
│ │ └── typography.css
│ │ ├── fonts
│ │ ├── DroidSans-Bold.ttf
│ │ └── DroidSans.ttf
│ │ ├── images
│ │ ├── collapse.gif
│ │ ├── expand.gif
│ │ ├── explorer_icons.png
│ │ ├── favicon-16x16.png
│ │ ├── favicon-32x32.png
│ │ ├── favicon.ico
│ │ ├── logo_small.png
│ │ ├── pet_store_api.png
│ │ ├── throbber.gif
│ │ └── wordnik_api.png
│ │ ├── lang
│ │ ├── en.js
│ │ ├── es.js
│ │ ├── fr.js
│ │ ├── geo.js
│ │ ├── it.js
│ │ ├── ja.js
│ │ ├── ko-kr.js
│ │ ├── pl.js
│ │ ├── pt.js
│ │ ├── ru.js
│ │ ├── tr.js
│ │ ├── translator.js
│ │ └── zh-cn.js
│ │ ├── lib
│ │ ├── backbone-min.js
│ │ ├── es5-shim.js
│ │ ├── handlebars-2.0.0.js
│ │ ├── highlight.7.3.pack.js
│ │ ├── highlight.9.1.0.pack.js
│ │ ├── highlight.9.1.0.pack_extended.js
│ │ ├── jquery-1.8.0.min.js
│ │ ├── jquery.ba-bbq.min.js
│ │ ├── jquery.slideto.min.js
│ │ ├── jquery.wiggle.min.js
│ │ ├── js-yaml.min.js
│ │ ├── jsoneditor.min.js
│ │ ├── lodash.min.js
│ │ ├── marked.js
│ │ ├── object-assign-pollyfill.js
│ │ ├── swagger-oauth.js
│ │ ├── underscore-min.js
│ │ └── underscore-min.map
│ │ └── swagger-ui.min.js
└── web.config
├── resources
├── assets
│ ├── js
│ │ ├── app.js
│ │ ├── bootstrap.js
│ │ └── components
│ │ │ └── Example.vue
│ └── sass
│ │ ├── _variables.scss
│ │ └── app.scss
├── lang
│ └── en
│ │ ├── auth.php
│ │ ├── pagination.php
│ │ ├── passwords.php
│ │ └── validation.php
└── views
│ ├── api.blade.php
│ ├── vendor
│ └── l5-swagger
│ │ ├── .gitkeep
│ │ └── index.blade.php
│ └── welcome.blade.php
├── routes
├── api.php
├── channels.php
├── console.php
└── web.php
├── server.php
├── storage
├── api-docs
│ └── api-docs.json
├── app
│ ├── .gitignore
│ └── public
│ │ └── .gitignore
├── framework
│ ├── .gitignore
│ ├── cache
│ │ └── .gitignore
│ ├── sessions
│ │ └── .gitignore
│ ├── testing
│ │ └── .gitignore
│ └── views
│ │ └── .gitignore
└── logs
│ └── .gitignore
├── tests
├── CreatesApplication.php
├── Feature
│ └── ExampleTest.php
├── TestCase.php
└── Unit
│ └── ExampleTest.php
└── webpack.mix.js
/.env.example:
--------------------------------------------------------------------------------
1 | APP_NAME=Laravel
2 | APP_ENV=local
3 | APP_KEY=
4 | APP_DEBUG=true
5 | APP_LOG_LEVEL=debug
6 | APP_URL=http://localhost
7 |
8 | DB_CONNECTION=mysql
9 | DB_HOST=127.0.0.1
10 | DB_PORT=3306
11 | DB_DATABASE=homestead
12 | DB_USERNAME=homestead
13 | DB_PASSWORD=secret
14 |
15 | BROADCAST_DRIVER=log
16 | CACHE_DRIVER=file
17 | SESSION_DRIVER=file
18 | QUEUE_DRIVER=sync
19 |
20 | REDIS_HOST=127.0.0.1
21 | REDIS_PASSWORD=null
22 | REDIS_PORT=6379
23 |
24 | MAIL_DRIVER=smtp
25 | MAIL_HOST=smtp.mailtrap.io
26 | MAIL_PORT=2525
27 | MAIL_USERNAME=null
28 | MAIL_PASSWORD=null
29 | MAIL_ENCRYPTION=null
30 |
31 | PUSHER_APP_ID=
32 | PUSHER_APP_KEY=
33 | PUSHER_APP_SECRET=
34 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 | *.css linguist-vendored
3 | *.scss linguist-vendored
4 | *.js linguist-vendored
5 | CHANGELOG.md export-ignore
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /public/hot
3 | /public/storage
4 | /storage/*.key
5 | /vendor
6 | /.idea
7 | /.vagrant
8 | Homestead.json
9 | Homestead.yaml
10 | npm-debug.log
11 | .env
12 | /nbproject/private/
13 | nbproject/
14 | nbproject/project.xml
15 | nbproject/project.properties
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # A modern REST API in Laravel 5
2 |
3 | Very sophisticated REST API using [Laravel 5.4](https://laravel.com). You can find all what you need in this example to create an API of your dream.
4 |
5 | #### We use in this Example :
6 |
7 | - [Dingo API package](https://github.com/dingo/api/)
8 |
9 | - How to use [Laravel Transformer]( http://fractal.thephpleague.com/transformers/) to customise the response.
10 |
11 | - Authentication using [Laravel Passport](https://laravel.com/docs/5.4/passport)
12 |
13 | - Create a unique slug using [Eloquent-Sluggable](https://github.com/cviebrock/eloquent-sluggable)
14 |
15 |
16 |
17 |
18 | ##### The project is still under developement, you may find an update if you back later.
19 |
20 |
21 |
22 | #### You can find ademo here :
23 | https://demo.halimlardjane.com/laravel-rest
24 |
25 |
26 | ### Installation Step by Step:
27 |
28 | 1- After you pull up the project, browse to the folder with your terminal and run:
29 |
30 | > composer install
31 |
32 |
33 | 2- To generate Laravel key, in your Terminal run:
34 |
35 | > php artisan key:generate
36 |
37 |
38 | 3- Create a Database in Your MySQL (choose a name, for example: librarydb)
39 |
40 | 4- Create an new file .env in the base folder containing a copy of the file .env.example, and update the cresential of databases connexion
41 |
42 | DB_CONNECTION=mysql
43 | DB_HOST=127.0.0.1
44 | DB_PORT=3306
45 | DB_DATABASE=librarydb
46 | DB_USERNAME=root
47 | DB_PASSWORD=
48 |
49 | Make sure also to out at API_PREFIX=api in your .env file Like this
50 |
51 | API_PREFIX=api
52 | API_NAME="Laravel API"
53 | API_VERSION=v1
54 | API_DEBUG=false
55 |
56 |
57 | 5- To migrate the database, In your Terminal run:
58 |
59 | > php artisan migrate
60 |
61 |
62 | 6- To fill the tables with some dummy data, In your Terminal run:
63 |
64 | > php artisan db:seed
65 |
66 |
67 | 7- To run the server and test the API, In your Terminal run:
68 |
69 | > php artisan serve
70 |
71 |
72 |
73 | 
74 |
75 |
76 |
77 | 8- Under construction...
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/app/Console/Kernel.php:
--------------------------------------------------------------------------------
1 | command('inspire')
28 | // ->hourly();
29 | }
30 |
31 | /**
32 | * Register the Closure based commands for the application.
33 | *
34 | * @return void
35 | */
36 | protected function commands()
37 | {
38 | require base_path('routes/console.php');
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/Exceptions/Handler.php:
--------------------------------------------------------------------------------
1 | expectsJson()) {
60 | return response()->json(['error' => 'Unauthenticated.'], 401);
61 | }
62 |
63 | return redirect()->guest(route('login'));
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/AuthorBookController.php:
--------------------------------------------------------------------------------
1 | response->error('Could not find the author', 404); // Use this by default
24 | return $this->response->errorNotFound('Could not find the author'); // Use this if you you using Dingo Api Routing Helpers
25 | }
26 |
27 | $books = $author->books()->paginate(10);
28 | //$books = $author->PaginateBooks();
29 | return $this->response->paginator($books, new \App\Transformer\BookTransformer());
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/AuthorController.php:
--------------------------------------------------------------------------------
1 | count()) {
29 | //return response()->json(['data' => $author]); // Use this by default
30 | //return $this->response->array($author->toArray()); // Use this if you using Dingo Api Routing Helpers
31 | //return $this->response->collection($languages, new LanguagesTransformer()); // Use this if you using Fractal <=> Create a resource collection transformer
32 | return $this->response->paginator($author, new AuthorTransformer); // Use this if you using Fractal Responding With Paginated Items
33 | }
34 | else {
35 | //return response()->json(['message' => 'Could not find the author', 'status_code'=> '404'], 404); // Use this by default
36 | //return $this->response->errorNotFound();
37 | return $this->response->errorNotFound('Could not find the author'); // Use this if you you using Dingo Api Routing Helpers
38 | }
39 | }
40 |
41 | /**
42 | * Store a newly created resource in storage.
43 | *
44 | * @param \Illuminate\Http\Request $request
45 | * @return \Illuminate\Http\Response
46 | */
47 | public function store(Request $request) {
48 | $input = $request->all();
49 | $validator = $this->validator_create($input);
50 | if ($validator->fails()) {
51 | //return $this->response->error('Could not create new author.', 400); // You can use this
52 | //return $this->response->errorBadRequest('Could not create new author.'); // or this
53 | return Response::json(array( // Better if use this with errors validation
54 | 'message' => 'Could not create new author.',
55 | 'errors' => $validator->errors(),
56 | 'status_code' => 400
57 | ), 400);
58 | }
59 |
60 | if(Author::create($input)){
61 | return $this->response->created();
62 | //return response()->setStatusCode(201, 'The resource is created successfully!');
63 | //response()->json(['status' => 'The resource is created successfully'], 200);
64 | //response('The resource is created successfully, 200);
65 | }
66 | else{
67 | //return $this->response->error('could_not_create_author', 500); // you can use this
68 | return $this->response->errorInternal('could_not_create_author'); // or this
69 | }
70 | }
71 |
72 | /**
73 | * Display the specified resource.
74 | *
75 | * @param int $id
76 | * @return \Illuminate\Http\Response
77 | */
78 | public function show($id) {
79 | $author = Author::find($id);
80 | if (!$author) {
81 | //return $this->response->error('Could not find the author', 404); // Use this by default
82 | return $this->response->errorNotFound('Could not find the author'); // Use this if you you using Dingo Api Routing Helpers
83 | }
84 | //return response()->json(['data' => $author]); // Use this by default
85 | //return $this->response->array($author->toArray()); // Use this if you using Dingo Api Routing Helpers
86 | return $this->response->item($author, new AuthorTransformer()); // Use this if you using Fractal
87 | }
88 |
89 | /**
90 | * Update the specified resource in storage.
91 | *
92 | * @param \Illuminate\Http\Request $request
93 | * @param int $id
94 | * @return \Illuminate\Http\Response
95 | */
96 | public function update(Request $request, $id) {
97 | $author = Author::find($id);
98 | if (!$author) {
99 | //return $this->response->error('Could not find the author', 404);
100 | return $this->response->errorNotFound('Could not find the author');
101 | }
102 |
103 | $input = $request->all();
104 | $validator = $this->validator_update($input, $id);
105 | if ($validator->fails()) {
106 | //return $this->response->error('Could not update a author.', 400); // You can use this
107 | //return $this->response->errorBadRequest('Could not update a author.'); // or this
108 | return Response::json(array( // Better if use this with errors validation
109 | 'message' => 'Could not update a author.',
110 | 'errors' => $validator->errors(),
111 | 'status_code' => 400
112 | ), 400);
113 | }
114 |
115 | $author->fill($input);
116 | if($author->save()){
117 | return $this->response->noContent(); // noContent -> HTTP Code 304
118 | }
119 | else{
120 | //return $this->response->error('could_not_update_author', 500); // you can use this
121 | return $this->response->errorInternal('could_not_update_author'); // or this
122 | }
123 | }
124 |
125 | /**
126 | * Remove the specified resource from storage.
127 | *
128 | * @param int $id
129 | * @return \Illuminate\Http\Response
130 | */
131 | public function destroy($id) {
132 | $author = Author::find($id);
133 | if (!$author) {
134 | //return $this->response->error('Could not find the author', 404);
135 | return $this->response->errorNotFound('Could not find the author');
136 | }
137 |
138 | if($author->delete()){ // physical delete
139 | return $this->response->noContent();
140 | }
141 | else{
142 | //return $this->response->error('could_not_delete_author', 500);
143 | return $this->response->errorInternal('could_not_delete_author');
144 | }
145 | }
146 |
147 | /**
148 | *
149 | * @param type $data
150 | * @return type
151 | */
152 | private function validator_create($data){
153 | return Validator::make($data, [
154 | 'first_name' => 'required|max:25',
155 | 'last_name' => 'required|max:25',
156 | ]);
157 | }
158 |
159 | /**
160 | *
161 | * @param type $data
162 | * @return type
163 | */
164 | private function validator_update($data, $language_id){
165 | $rules = array();
166 | if (array_key_exists('first_name', $data)){
167 | $rules['language_name'] = 'required|max:25';
168 | }
169 | if (array_key_exists('last_name', $data)){
170 | $rules['last_name'] = 'required|max:25';
171 | }
172 | return Validator::make($data,
173 | $rules
174 | );
175 | }
176 |
177 | }
178 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/LanguageBookController.php:
--------------------------------------------------------------------------------
1 | response->error('Could not find the language', 404); // Use this by default
23 | return $this->response->errorNotFound('Could not find the language'); // Use this if you you using Dingo Api Routing Helpers
24 | }
25 |
26 | $books = $language->books()->paginate(10);
27 | //$books = $language->PaginateBooks();
28 | return $this->response->paginator($books, new \App\Transformer\BookTransformer());
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/LanguagesController.php:
--------------------------------------------------------------------------------
1 | count()) {
29 | //return response()->json(['data' => $languages]); // Use this by default
30 | //return $this->response->array($languages->toArray()); // Use this if you using Dingo Api Routing Helpers
31 | //return $this->response->collection($languages, new LanguagesTransformer()); // Use this if you using Fractal <=> Create a resource collection transformer
32 | return $this->response->paginator($languages, new LanguagesTransformer); // Use this if you using Fractal Responding With Paginated Items
33 | }
34 | else {
35 | //return response()->json(['message' => 'Could not find the languages', 'status_code'=> '404'], 404); // Use this by default
36 | //return $this->response->errorNotFound();
37 | return $this->response->errorNotFound('Could not find the languages'); // Use this if you you using Dingo Api Routing Helpers
38 | }
39 | }
40 |
41 | /**
42 | * Store a newly created resource in storage.
43 | *
44 | * @param \Illuminate\Http\Request $request
45 | * @return \Illuminate\Http\Response
46 | */
47 | public function store(Request $request) {
48 | $input = $request->all();
49 | $validator = $this->validator_create($input);
50 | if ($validator->fails()) {
51 | //return $this->response->error('Could not create new language.', 400); // You can use this
52 | //return $this->response->errorBadRequest('Could not create new language.'); // or this
53 | return Response::json(array( // Better if use this with errors validation
54 | 'message' => 'Could not create new language.',
55 | 'errors' => $validator->errors(),
56 | 'status_code' => 400
57 | ), 400);
58 | }
59 |
60 | if(Languages::create($input)){
61 | return $this->response->created();
62 | //return response()->setStatusCode(201, 'The resource is created successfully!');
63 | //response()->json(['status' => 'The resource is created successfully'], 200);
64 | //response('The resource is created successfully, 200);
65 | }
66 | else{
67 | //return $this->response->error('could_not_create_language', 500); // you can use this
68 | return $this->response->errorInternal('could_not_create_language'); // or this
69 | }
70 | }
71 |
72 | /**
73 | * Display the specified resource.
74 | *
75 | * @param int $id
76 | * @return \Illuminate\Http\Response
77 | */
78 | public function show($id) {
79 | $language = Languages::find($id);
80 | if (!$language) {
81 | //return $this->response->error('Could not find the language', 404); // Use this by default
82 | return $this->response->errorNotFound('Could not find the language'); // Use this if you you using Dingo Api Routing Helpers
83 | }
84 | //return response()->json(['data' => $language]); // Use this by default
85 | //return $this->response->array($language->toArray()); // Use this if you using Dingo Api Routing Helpers
86 | return $this->response->item($language, new LanguagesTransformer()); // Use this if you using Fractal
87 | }
88 |
89 | /**
90 | * Update the specified resource in storage.
91 | *
92 | * @param \Illuminate\Http\Request $request
93 | * @param int $id
94 | * @return \Illuminate\Http\Response
95 | */
96 | public function update(Request $request, $id) {
97 | $language = Languages::find($id);
98 | if (!$language) {
99 | //return $this->response->error('Could not find the language', 404);
100 | return $this->response->errorNotFound('Could not find the language');
101 | }
102 |
103 | $input = $request->all();
104 | $validator = $this->validator_update($input, $id);
105 | if ($validator->fails()) {
106 | //return $this->response->error('Could not update a language.', 400); // You can use this
107 | //return $this->response->errorBadRequest('Could not update a language.'); // or this
108 | return Response::json(array( // Better if use this with errors validation
109 | 'message' => 'Could not update a language.',
110 | 'errors' => $validator->errors(),
111 | 'status_code' => 400
112 | ), 400);
113 | }
114 |
115 | $language->fill($input);
116 | if($language->save()){
117 | return $this->response->noContent(); // noContent -> HTTP Code 304
118 | }
119 | else{
120 | //return $this->response->error('could_not_update_language', 500); // you can use this
121 | return $this->response->errorInternal('could_not_update_language'); // or this
122 | }
123 | }
124 |
125 | /**
126 | * Remove the specified resource from storage.
127 | *
128 | * @param int $id
129 | * @return \Illuminate\Http\Response
130 | */
131 | public function destroy($id) {
132 | $language = Languages::find($id);
133 | if (!$language) {
134 | //return $this->response->error('Could not find the language', 404);
135 | return $this->response->errorNotFound('Could not find the language');
136 | }
137 |
138 | if($language->delete()){ // physical delete
139 | return $this->response->noContent();
140 | }
141 | else{
142 | //return $this->response->error('could_not_delete_language', 500);
143 | return $this->response->errorInternal('could_not_delete_language');
144 | }
145 | }
146 |
147 | /**
148 | *
149 | * @param type $data
150 | * @return type
151 | */
152 | private function validator_create($data){
153 | return Validator::make($data, [
154 | 'language_name' => 'required|max:45',
155 | 'language_code' => 'required|max:2|unique:languages',
156 | ]);
157 | }
158 |
159 | /**
160 | *
161 | * @param type $data
162 | * @return type
163 | */
164 | private function validator_update($data, $language_id){
165 | $rules = array();
166 | if (array_key_exists('language_name', $data)){
167 | $rules['language_name'] = 'required|max:45';
168 | }
169 | if (array_key_exists('language_code', $data)){
170 | $rules['language_code'] = 'required|max:2|unique:languages,language_code, ' . $language_id . ',language_id';
171 | }
172 | return Validator::make($data,
173 | $rules
174 | );
175 | }
176 |
177 | }
178 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/SwaggerController.php:
--------------------------------------------------------------------------------
1 | middleware('guest');
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/LoginController.php:
--------------------------------------------------------------------------------
1 | middleware('guest')->except('logout');
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/RegisterController.php:
--------------------------------------------------------------------------------
1 | middleware('guest');
40 | }
41 |
42 | /**
43 | * Get a validator for an incoming registration request.
44 | *
45 | * @param array $data
46 | * @return \Illuminate\Contracts\Validation\Validator
47 | */
48 | protected function validator(array $data)
49 | {
50 | return Validator::make($data, [
51 | 'name' => 'required|string|max:255',
52 | 'email' => 'required|string|email|max:255|unique:users',
53 | 'password' => 'required|string|min:6|confirmed',
54 | ]);
55 | }
56 |
57 | /**
58 | * Create a new user instance after a valid registration.
59 | *
60 | * @param array $data
61 | * @return User
62 | */
63 | protected function create(array $data)
64 | {
65 | return User::create([
66 | 'name' => $data['name'],
67 | 'email' => $data['email'],
68 | 'password' => bcrypt($data['password']),
69 | ]);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/ResetPasswordController.php:
--------------------------------------------------------------------------------
1 | middleware('guest');
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Controller.php:
--------------------------------------------------------------------------------
1 | [
30 | \App\Http\Middleware\EncryptCookies::class,
31 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
32 | \Illuminate\Session\Middleware\StartSession::class,
33 | // \Illuminate\Session\Middleware\AuthenticateSession::class,
34 | \Illuminate\View\Middleware\ShareErrorsFromSession::class,
35 | \App\Http\Middleware\VerifyCsrfToken::class,
36 | \Illuminate\Routing\Middleware\SubstituteBindings::class,
37 | ],
38 |
39 | 'api' => [
40 | 'throttle:60,1',
41 | 'bindings',
42 | ],
43 | ];
44 |
45 | /**
46 | * The application's route middleware.
47 | *
48 | * These middleware may be assigned to groups or used individually.
49 | *
50 | * @var array
51 | */
52 | protected $routeMiddleware = [
53 | 'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
54 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
55 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
56 | 'can' => \Illuminate\Auth\Middleware\Authorize::class,
57 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
58 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
59 | ];
60 | }
61 |
--------------------------------------------------------------------------------
/app/Http/Middleware/EncryptCookies.php:
--------------------------------------------------------------------------------
1 | check()) {
21 | return redirect('/home');
22 | }
23 |
24 | return $next($request);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Http/Middleware/TrimStrings.php:
--------------------------------------------------------------------------------
1 | hasMany('App\Models\Book', 'foreign_key');
37 | return $this->hasMany('App\Models\Book', 'author_id', 'author_id');
38 | }
39 |
40 | /**
41 | *
42 | * @return type
43 | */
44 | public function PaginateBooks(){
45 | return $this->books()->paginate(10);
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/app/Models/Book.php:
--------------------------------------------------------------------------------
1 | [
44 | 'source' => 'title'
45 | ]
46 | ];
47 | }
48 |
49 | /**
50 | *
51 | * @return type
52 | */
53 | public function author(){
54 | return $this->belongsTo('App\Models\Author', 'author_id', 'author_id');
55 | }
56 |
57 | /**
58 | *
59 | * @return type
60 | */
61 | public function language(){
62 | return $this->belongsTo('App\Models\Languages', 'language_id');
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/app/Models/Languages.php:
--------------------------------------------------------------------------------
1 | hasMany('App\Models\Book', 'language_id');
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/app/Models/Users.php:
--------------------------------------------------------------------------------
1 | 'App\Policies\ModelPolicy',
17 | ];
18 |
19 | /**
20 | * Register any authentication / authorization services.
21 | *
22 | * @return void
23 | */
24 | public function boot()
25 | {
26 | $this->registerPolicies();
27 |
28 | //
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/Providers/BroadcastServiceProvider.php:
--------------------------------------------------------------------------------
1 | [
17 | 'App\Listeners\EventListener',
18 | ],
19 | ];
20 |
21 | /**
22 | * Register any events for your application.
23 | *
24 | * @return void
25 | */
26 | public function boot()
27 | {
28 | parent::boot();
29 |
30 | //
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/Providers/RouteServiceProvider.php:
--------------------------------------------------------------------------------
1 | mapApiRoutes();
39 |
40 | $this->mapWebRoutes();
41 |
42 | //
43 | }
44 |
45 | /**
46 | * Define the "web" routes for the application.
47 | *
48 | * These routes all receive session state, CSRF protection, etc.
49 | *
50 | * @return void
51 | */
52 | protected function mapWebRoutes()
53 | {
54 | Route::middleware('web')
55 | ->namespace($this->namespace)
56 | ->group(base_path('routes/web.php'));
57 | }
58 |
59 | /**
60 | * Define the "api" routes for the application.
61 | *
62 | * These routes are typically stateless.
63 | *
64 | * @return void
65 | */
66 | protected function mapApiRoutes()
67 | {
68 | Route::prefix('api')
69 | ->middleware('api')
70 | ->namespace($this->namespace)
71 | ->group(base_path('routes/api.php'));
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/app/Transformer/AuthorBookTransformer.php:
--------------------------------------------------------------------------------
1 | (int) $author->author_id,
19 | 'first_name' => $author->first_name,
20 | 'last_name' => $author->last_name,
21 | // 'created_at' => $author->created_at,
22 | // 'updated_at' => $author->updated_at,
23 | 'link' => [
24 | [
25 | 'uri' => url('api/author/'.$author->author_id)
26 | ]
27 | ],
28 | ];
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/app/Transformer/AuthorTransformer.php:
--------------------------------------------------------------------------------
1 | (int) $author->author_id,
18 | 'first_name' => $author->first_name,
19 | 'last_name' => $author->last_name,
20 | // 'created_at' => $author->created_at,
21 | // 'updated_at' => $author->updated_at,
22 | 'link' => [
23 | [
24 | 'uri' => url('api/author/'.$author->author_id),
25 | 'book' => url('api/author/'.$author->author_id.'/book')
26 | ]
27 | ],
28 | ];
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/app/Transformer/BookTransformer.php:
--------------------------------------------------------------------------------
1 | (int) $book->book_id,
18 | 'title' => $book->title,
19 | 'slug' => $book->slug,
20 | 'description' => $book->description,
21 | 'ISBN' => $book->ISBN,
22 | 'pages' => $book->pages,
23 | 'published_at' => $book->published_at,
24 | 'language_id' => $book->language_id,
25 | 'author_id' => $book->author_id,
26 | // 'created_at' => $book->created_at,
27 | // 'updated_at' => $book->updated_at,
28 | 'link' => [
29 | [
30 | 'uri' => url('api/book/'.$book->book_id),
31 | 'language' => url('api/language/'.$book->language_id),
32 | 'author' => url('api/author/'.$book->author_id)
33 | ]
34 | ],
35 | ];
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/app/Transformer/LanguagesTransformer.php:
--------------------------------------------------------------------------------
1 | (int) $language->language_id,
18 | 'language_name' => $language->language_name,
19 | 'language_code' => $language->language_code,
20 | 'link' => [
21 | [
22 | 'uri' => url('api/language/'.$language->language_id),
23 | 'book' => url('api/language/'.$language->language_id.'/book')
24 | ]
25 | ],
26 | ];
27 | }
28 |
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/app/Transformer/UsersTransformer.php:
--------------------------------------------------------------------------------
1 | (int) $user->user_id,
18 | 'first_name' => $user->first_name,
19 | 'last_name' => $user->last_name,
20 | 'phone' => $user->phone,
21 | 'email' => $user->email,
22 | 'role' => $user->role,
23 | 'status' => $user->status,
24 | //'created_at' => $user->created_at,
25 | //'updated_at' => $user->updated_at,
26 | 'link' => [
27 | [
28 | 'uri' => url('api/users/'.$user->user_id)
29 | ]
30 | ],
31 | ];
32 | }
33 |
34 | /**
35 | *
36 | * @param \App\Transformer\Users $user
37 | * @return type
38 | */
39 | public function includePhone(Users $user){
40 | $phone = $user->phone;
41 | return $this->item($phone, new UsersTransformer);
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/artisan:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 | make(Illuminate\Contracts\Console\Kernel::class);
32 |
33 | $status = $kernel->handle(
34 | $input = new Symfony\Component\Console\Input\ArgvInput,
35 | new Symfony\Component\Console\Output\ConsoleOutput
36 | );
37 |
38 | /*
39 | |--------------------------------------------------------------------------
40 | | Shutdown The Application
41 | |--------------------------------------------------------------------------
42 | |
43 | | Once Artisan has finished running, we will fire off the shutdown events
44 | | so that any final work may be done by the application before we shut
45 | | down the process. This is the last thing to happen to the request.
46 | |
47 | */
48 |
49 | $kernel->terminate($input, $status);
50 |
51 | exit($status);
52 |
--------------------------------------------------------------------------------
/bootstrap/app.php:
--------------------------------------------------------------------------------
1 | singleton(
30 | Illuminate\Contracts\Http\Kernel::class,
31 | App\Http\Kernel::class
32 | );
33 |
34 | $app->singleton(
35 | Illuminate\Contracts\Console\Kernel::class,
36 | App\Console\Kernel::class
37 | );
38 |
39 | $app->singleton(
40 | Illuminate\Contracts\Debug\ExceptionHandler::class,
41 | App\Exceptions\Handler::class
42 | );
43 |
44 | /*
45 | |--------------------------------------------------------------------------
46 | | Custom new Serializer.
47 | |--------------------------------------------------------------------------
48 | |
49 | */
50 |
51 | //$app['Dingo\Api\Transformer\Factory']->setAdapter(function ($app) {
52 | // $fractal = new League\Fractal\Manager;
53 | // $fractal->setSerializer(new App\Serializers\NoDataArraySerializer);
54 | // return new Dingo\Api\Transformer\Adapter\Fractal($fractal);
55 | //});
56 |
57 | /*
58 | |--------------------------------------------------------------------------
59 | | Return The Application
60 | |--------------------------------------------------------------------------
61 | |
62 | | This script returns the application instance. The instance is given to
63 | | the calling script so we can separate the building of the instances
64 | | from the actual running of the application and sending responses.
65 | |
66 | */
67 |
68 | return $app;
69 |
--------------------------------------------------------------------------------
/bootstrap/autoload.php:
--------------------------------------------------------------------------------
1 | =5.6.4",
9 | "cviebrock/eloquent-sluggable": "^4.2",
10 | "darkaonline/l5-swagger": "~4.0",
11 | "dingo/api": "1.0.x@dev",
12 | "laravel/framework": "5.4.*",
13 | "laravel/tinker": "~1.0",
14 | "league/fractal": "^0.16.0"
15 | },
16 | "require-dev": {
17 | "fzaninotto/faker": "~1.4",
18 | "mockery/mockery": "0.9.*",
19 | "phpunit/phpunit": "~5.7"
20 | },
21 | "autoload": {
22 | "classmap": [
23 | "database"
24 | ],
25 | "psr-4": {
26 | "App\\": "app/"
27 | }
28 | },
29 | "autoload-dev": {
30 | "psr-4": {
31 | "Tests\\": "tests/"
32 | }
33 | },
34 | "scripts": {
35 | "post-root-package-install": [
36 | "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
37 | ],
38 | "post-create-project-cmd": [
39 | "php artisan key:generate"
40 | ],
41 | "post-install-cmd": [
42 | "Illuminate\\Foundation\\ComposerScripts::postInstall",
43 | "php artisan optimize"
44 | ],
45 | "post-update-cmd": [
46 | "Illuminate\\Foundation\\ComposerScripts::postUpdate",
47 | "php artisan optimize"
48 | ]
49 | },
50 | "config": {
51 | "preferred-install": "dist",
52 | "sort-packages": true,
53 | "optimize-autoloader": true
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/config/auth.php:
--------------------------------------------------------------------------------
1 | [
17 | 'guard' => 'web',
18 | 'passwords' => 'users',
19 | ],
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Authentication Guards
24 | |--------------------------------------------------------------------------
25 | |
26 | | Next, you may define every authentication guard for your application.
27 | | Of course, a great default configuration has been defined for you
28 | | here which uses session storage and the Eloquent user provider.
29 | |
30 | | All authentication drivers have a user provider. This defines how the
31 | | users are actually retrieved out of your database or other storage
32 | | mechanisms used by this application to persist your user's data.
33 | |
34 | | Supported: "session", "token"
35 | |
36 | */
37 |
38 | 'guards' => [
39 | 'web' => [
40 | 'driver' => 'session',
41 | 'provider' => 'users',
42 | ],
43 |
44 | 'api' => [
45 | 'driver' => 'token',
46 | 'provider' => 'users',
47 | ],
48 | ],
49 |
50 | /*
51 | |--------------------------------------------------------------------------
52 | | User Providers
53 | |--------------------------------------------------------------------------
54 | |
55 | | All authentication drivers have a user provider. This defines how the
56 | | users are actually retrieved out of your database or other storage
57 | | mechanisms used by this application to persist your user's data.
58 | |
59 | | If you have multiple user tables or models you may configure multiple
60 | | sources which represent each model / table. These sources may then
61 | | be assigned to any extra authentication guards you have defined.
62 | |
63 | | Supported: "database", "eloquent"
64 | |
65 | */
66 |
67 | 'providers' => [
68 | 'users' => [
69 | 'driver' => 'eloquent',
70 | 'model' => App\User::class,
71 | ],
72 |
73 | // 'users' => [
74 | // 'driver' => 'database',
75 | // 'table' => 'users',
76 | // ],
77 | ],
78 |
79 | /*
80 | |--------------------------------------------------------------------------
81 | | Resetting Passwords
82 | |--------------------------------------------------------------------------
83 | |
84 | | You may specify multiple password reset configurations if you have more
85 | | than one user table or model in the application and you want to have
86 | | separate password reset settings based on the specific user types.
87 | |
88 | | The expire time is the number of minutes that the reset token should be
89 | | considered valid. This security feature keeps tokens short-lived so
90 | | they have less time to be guessed. You may change this as needed.
91 | |
92 | */
93 |
94 | 'passwords' => [
95 | 'users' => [
96 | 'provider' => 'users',
97 | 'table' => 'password_resets',
98 | 'expire' => 60,
99 | ],
100 | ],
101 |
102 | ];
103 |
--------------------------------------------------------------------------------
/config/broadcasting.php:
--------------------------------------------------------------------------------
1 | env('BROADCAST_DRIVER', 'null'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Broadcast Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may define all of the broadcast connections that will be used
26 | | to broadcast events to other systems or over websockets. Samples of
27 | | each available type of connection are provided inside this array.
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'pusher' => [
34 | 'driver' => 'pusher',
35 | 'key' => env('PUSHER_APP_KEY'),
36 | 'secret' => env('PUSHER_APP_SECRET'),
37 | 'app_id' => env('PUSHER_APP_ID'),
38 | 'options' => [
39 | //
40 | ],
41 | ],
42 |
43 | 'redis' => [
44 | 'driver' => 'redis',
45 | 'connection' => 'default',
46 | ],
47 |
48 | 'log' => [
49 | 'driver' => 'log',
50 | ],
51 |
52 | 'null' => [
53 | 'driver' => 'null',
54 | ],
55 |
56 | ],
57 |
58 | ];
59 |
--------------------------------------------------------------------------------
/config/cache.php:
--------------------------------------------------------------------------------
1 | env('CACHE_DRIVER', 'file'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Cache Stores
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may define all of the cache "stores" for your application as
26 | | well as their drivers. You may even define multiple stores for the
27 | | same cache driver to group types of items stored in your caches.
28 | |
29 | */
30 |
31 | 'stores' => [
32 |
33 | 'apc' => [
34 | 'driver' => 'apc',
35 | ],
36 |
37 | 'array' => [
38 | 'driver' => 'array',
39 | ],
40 |
41 | 'database' => [
42 | 'driver' => 'database',
43 | 'table' => 'cache',
44 | 'connection' => null,
45 | ],
46 |
47 | 'file' => [
48 | 'driver' => 'file',
49 | 'path' => storage_path('framework/cache/data'),
50 | ],
51 |
52 | 'memcached' => [
53 | 'driver' => 'memcached',
54 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
55 | 'sasl' => [
56 | env('MEMCACHED_USERNAME'),
57 | env('MEMCACHED_PASSWORD'),
58 | ],
59 | 'options' => [
60 | // Memcached::OPT_CONNECT_TIMEOUT => 2000,
61 | ],
62 | 'servers' => [
63 | [
64 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'),
65 | 'port' => env('MEMCACHED_PORT', 11211),
66 | 'weight' => 100,
67 | ],
68 | ],
69 | ],
70 |
71 | 'redis' => [
72 | 'driver' => 'redis',
73 | 'connection' => 'default',
74 | ],
75 |
76 | ],
77 |
78 | /*
79 | |--------------------------------------------------------------------------
80 | | Cache Key Prefix
81 | |--------------------------------------------------------------------------
82 | |
83 | | When utilizing a RAM based store such as APC or Memcached, there might
84 | | be other applications utilizing the same cache. So, we'll specify a
85 | | value to get prefixed to all our keys so we can avoid collisions.
86 | |
87 | */
88 |
89 | 'prefix' => 'laravel',
90 |
91 | ];
92 |
--------------------------------------------------------------------------------
/config/database.php:
--------------------------------------------------------------------------------
1 | env('DB_CONNECTION', 'mysql'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Database Connections
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here are each of the database connections setup for your application.
24 | | Of course, examples of configuring each database platform that is
25 | | supported by Laravel is shown below to make development simple.
26 | |
27 | |
28 | | All database work in Laravel is done through the PHP PDO facilities
29 | | so make sure you have the driver for your particular database of
30 | | choice installed on your machine before you begin development.
31 | |
32 | */
33 |
34 | 'connections' => [
35 |
36 | 'sqlite' => [
37 | 'driver' => 'sqlite',
38 | 'database' => env('DB_DATABASE', database_path('database.sqlite')),
39 | 'prefix' => '',
40 | ],
41 |
42 | 'mysql' => [
43 | 'driver' => 'mysql',
44 | 'host' => env('DB_HOST', '127.0.0.1'),
45 | 'port' => env('DB_PORT', '3306'),
46 | 'database' => env('DB_DATABASE', 'forge'),
47 | 'username' => env('DB_USERNAME', 'forge'),
48 | 'password' => env('DB_PASSWORD', ''),
49 | 'unix_socket' => env('DB_SOCKET', ''),
50 | 'charset' => 'utf8mb4',
51 | 'collation' => 'utf8mb4_unicode_ci',
52 | 'prefix' => '',
53 | 'strict' => true,
54 | 'engine' => null,
55 | ],
56 |
57 | 'pgsql' => [
58 | 'driver' => 'pgsql',
59 | 'host' => env('DB_HOST', '127.0.0.1'),
60 | 'port' => env('DB_PORT', '5432'),
61 | 'database' => env('DB_DATABASE', 'forge'),
62 | 'username' => env('DB_USERNAME', 'forge'),
63 | 'password' => env('DB_PASSWORD', ''),
64 | 'charset' => 'utf8',
65 | 'prefix' => '',
66 | 'schema' => 'public',
67 | 'sslmode' => 'prefer',
68 | ],
69 |
70 | 'sqlsrv' => [
71 | 'driver' => 'sqlsrv',
72 | 'host' => env('DB_HOST', 'localhost'),
73 | 'port' => env('DB_PORT', '1433'),
74 | 'database' => env('DB_DATABASE', 'forge'),
75 | 'username' => env('DB_USERNAME', 'forge'),
76 | 'password' => env('DB_PASSWORD', ''),
77 | 'charset' => 'utf8',
78 | 'prefix' => '',
79 | ],
80 |
81 | ],
82 |
83 | /*
84 | |--------------------------------------------------------------------------
85 | | Migration Repository Table
86 | |--------------------------------------------------------------------------
87 | |
88 | | This table keeps track of all the migrations that have already run for
89 | | your application. Using this information, we can determine which of
90 | | the migrations on disk haven't actually been run in the database.
91 | |
92 | */
93 |
94 | 'migrations' => 'migrations',
95 |
96 | /*
97 | |--------------------------------------------------------------------------
98 | | Redis Databases
99 | |--------------------------------------------------------------------------
100 | |
101 | | Redis is an open source, fast, and advanced key-value store that also
102 | | provides a richer set of commands than a typical key-value systems
103 | | such as APC or Memcached. Laravel makes it easy to dig right in.
104 | |
105 | */
106 |
107 | 'redis' => [
108 |
109 | 'client' => 'predis',
110 |
111 | 'default' => [
112 | 'host' => env('REDIS_HOST', '127.0.0.1'),
113 | 'password' => env('REDIS_PASSWORD', null),
114 | 'port' => env('REDIS_PORT', 6379),
115 | 'database' => 0,
116 | ],
117 |
118 | ],
119 |
120 | ];
121 |
--------------------------------------------------------------------------------
/config/filesystems.php:
--------------------------------------------------------------------------------
1 | env('FILESYSTEM_DRIVER', 'local'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Default Cloud Filesystem Disk
21 | |--------------------------------------------------------------------------
22 | |
23 | | Many applications store files both locally and in the cloud. For this
24 | | reason, you may specify a default "cloud" driver here. This driver
25 | | will be bound as the Cloud disk implementation in the container.
26 | |
27 | */
28 |
29 | 'cloud' => env('FILESYSTEM_CLOUD', 's3'),
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Filesystem Disks
34 | |--------------------------------------------------------------------------
35 | |
36 | | Here you may configure as many filesystem "disks" as you wish, and you
37 | | may even configure multiple disks of the same driver. Defaults have
38 | | been setup for each driver as an example of the required options.
39 | |
40 | | Supported Drivers: "local", "ftp", "s3", "rackspace"
41 | |
42 | */
43 |
44 | 'disks' => [
45 |
46 | 'local' => [
47 | 'driver' => 'local',
48 | 'root' => storage_path('app'),
49 | ],
50 |
51 | 'public' => [
52 | 'driver' => 'local',
53 | 'root' => storage_path('app/public'),
54 | 'url' => env('APP_URL').'/storage',
55 | 'visibility' => 'public',
56 | ],
57 |
58 | 's3' => [
59 | 'driver' => 's3',
60 | 'key' => env('AWS_KEY'),
61 | 'secret' => env('AWS_SECRET'),
62 | 'region' => env('AWS_REGION'),
63 | 'bucket' => env('AWS_BUCKET'),
64 | ],
65 |
66 | ],
67 |
68 | ];
69 |
--------------------------------------------------------------------------------
/config/mail.php:
--------------------------------------------------------------------------------
1 | env('MAIL_DRIVER', 'smtp'),
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | SMTP Host Address
24 | |--------------------------------------------------------------------------
25 | |
26 | | Here you may provide the host address of the SMTP server used by your
27 | | applications. A default option is provided that is compatible with
28 | | the Mailgun mail service which will provide reliable deliveries.
29 | |
30 | */
31 |
32 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
33 |
34 | /*
35 | |--------------------------------------------------------------------------
36 | | SMTP Host Port
37 | |--------------------------------------------------------------------------
38 | |
39 | | This is the SMTP port used by your application to deliver e-mails to
40 | | users of the application. Like the host we have set this value to
41 | | stay compatible with the Mailgun e-mail application by default.
42 | |
43 | */
44 |
45 | 'port' => env('MAIL_PORT', 587),
46 |
47 | /*
48 | |--------------------------------------------------------------------------
49 | | Global "From" Address
50 | |--------------------------------------------------------------------------
51 | |
52 | | You may wish for all e-mails sent by your application to be sent from
53 | | the same address. Here, you may specify a name and address that is
54 | | used globally for all e-mails that are sent by your application.
55 | |
56 | */
57 |
58 | 'from' => [
59 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
60 | 'name' => env('MAIL_FROM_NAME', 'Example'),
61 | ],
62 |
63 | /*
64 | |--------------------------------------------------------------------------
65 | | E-Mail Encryption Protocol
66 | |--------------------------------------------------------------------------
67 | |
68 | | Here you may specify the encryption protocol that should be used when
69 | | the application send e-mail messages. A sensible default using the
70 | | transport layer security protocol should provide great security.
71 | |
72 | */
73 |
74 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'),
75 |
76 | /*
77 | |--------------------------------------------------------------------------
78 | | SMTP Server Username
79 | |--------------------------------------------------------------------------
80 | |
81 | | If your SMTP server requires a username for authentication, you should
82 | | set it here. This will get used to authenticate with your server on
83 | | connection. You may also set the "password" value below this one.
84 | |
85 | */
86 |
87 | 'username' => env('MAIL_USERNAME'),
88 |
89 | 'password' => env('MAIL_PASSWORD'),
90 |
91 | /*
92 | |--------------------------------------------------------------------------
93 | | Sendmail System Path
94 | |--------------------------------------------------------------------------
95 | |
96 | | When using the "sendmail" driver to send e-mails, we will need to know
97 | | the path to where Sendmail lives on this server. A default path has
98 | | been provided here, which will work well on most of your systems.
99 | |
100 | */
101 |
102 | 'sendmail' => '/usr/sbin/sendmail -bs',
103 |
104 | /*
105 | |--------------------------------------------------------------------------
106 | | Markdown Mail Settings
107 | |--------------------------------------------------------------------------
108 | |
109 | | If you are using Markdown based email rendering, you may configure your
110 | | theme and component paths here, allowing you to customize the design
111 | | of the emails. Or, you may simply stick with the Laravel defaults!
112 | |
113 | */
114 |
115 | 'markdown' => [
116 | 'theme' => 'default',
117 |
118 | 'paths' => [
119 | resource_path('views/vendor/mail'),
120 | ],
121 | ],
122 |
123 | ];
124 |
--------------------------------------------------------------------------------
/config/queue.php:
--------------------------------------------------------------------------------
1 | env('QUEUE_DRIVER', '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 | 'database' => [
38 | 'driver' => 'database',
39 | 'table' => 'jobs',
40 | 'queue' => 'default',
41 | 'retry_after' => 90,
42 | ],
43 |
44 | 'beanstalkd' => [
45 | 'driver' => 'beanstalkd',
46 | 'host' => 'localhost',
47 | 'queue' => 'default',
48 | 'retry_after' => 90,
49 | ],
50 |
51 | 'sqs' => [
52 | 'driver' => 'sqs',
53 | 'key' => 'your-public-key',
54 | 'secret' => 'your-secret-key',
55 | 'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id',
56 | 'queue' => 'your-queue-name',
57 | 'region' => 'us-east-1',
58 | ],
59 |
60 | 'redis' => [
61 | 'driver' => 'redis',
62 | 'connection' => 'default',
63 | 'queue' => 'default',
64 | 'retry_after' => 90,
65 | ],
66 |
67 | ],
68 |
69 | /*
70 | |--------------------------------------------------------------------------
71 | | Failed Queue Jobs
72 | |--------------------------------------------------------------------------
73 | |
74 | | These options configure the behavior of failed queue job logging so you
75 | | can control which database and table are used to store the jobs that
76 | | have failed. You may change them to any database / table you wish.
77 | |
78 | */
79 |
80 | 'failed' => [
81 | 'database' => env('DB_CONNECTION', 'mysql'),
82 | 'table' => 'failed_jobs',
83 | ],
84 |
85 | ];
86 |
--------------------------------------------------------------------------------
/config/services.php:
--------------------------------------------------------------------------------
1 | [
18 | 'domain' => env('MAILGUN_DOMAIN'),
19 | 'secret' => env('MAILGUN_SECRET'),
20 | ],
21 |
22 | 'ses' => [
23 | 'key' => env('SES_KEY'),
24 | 'secret' => env('SES_SECRET'),
25 | 'region' => 'us-east-1',
26 | ],
27 |
28 | 'sparkpost' => [
29 | 'secret' => env('SPARKPOST_SECRET'),
30 | ],
31 |
32 | 'stripe' => [
33 | 'model' => App\User::class,
34 | 'key' => env('STRIPE_KEY'),
35 | 'secret' => env('STRIPE_SECRET'),
36 | ],
37 |
38 | ];
39 |
--------------------------------------------------------------------------------
/config/session.php:
--------------------------------------------------------------------------------
1 | env('SESSION_DRIVER', '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 Encryption
39 | |--------------------------------------------------------------------------
40 | |
41 | | This option allows you to easily specify that all of your session data
42 | | should be encrypted before it is stored. All encryption will be run
43 | | automatically by Laravel and you can use the Session like normal.
44 | |
45 | */
46 |
47 | 'encrypt' => false,
48 |
49 | /*
50 | |--------------------------------------------------------------------------
51 | | Session File Location
52 | |--------------------------------------------------------------------------
53 | |
54 | | When using the native session driver, we need a location where session
55 | | files may be stored. A default has been set for you but a different
56 | | location may be specified. This is only needed for file sessions.
57 | |
58 | */
59 |
60 | 'files' => storage_path('framework/sessions'),
61 |
62 | /*
63 | |--------------------------------------------------------------------------
64 | | Session Database Connection
65 | |--------------------------------------------------------------------------
66 | |
67 | | When using the "database" or "redis" session drivers, you may specify a
68 | | connection that should be used to manage these sessions. This should
69 | | correspond to a connection in your database configuration options.
70 | |
71 | */
72 |
73 | 'connection' => null,
74 |
75 | /*
76 | |--------------------------------------------------------------------------
77 | | Session Database Table
78 | |--------------------------------------------------------------------------
79 | |
80 | | When using the "database" session driver, you may specify the table we
81 | | should use to manage the sessions. Of course, a sensible default is
82 | | provided for you; however, you are free to change this as needed.
83 | |
84 | */
85 |
86 | 'table' => 'sessions',
87 |
88 | /*
89 | |--------------------------------------------------------------------------
90 | | Session Cache Store
91 | |--------------------------------------------------------------------------
92 | |
93 | | When using the "apc" or "memcached" session drivers, you may specify a
94 | | cache store that should be used for these sessions. This value must
95 | | correspond with one of the application's configured cache stores.
96 | |
97 | */
98 |
99 | 'store' => null,
100 |
101 | /*
102 | |--------------------------------------------------------------------------
103 | | Session Sweeping Lottery
104 | |--------------------------------------------------------------------------
105 | |
106 | | Some session drivers must manually sweep their storage location to get
107 | | rid of old sessions from storage. Here are the chances that it will
108 | | happen on a given request. By default, the odds are 2 out of 100.
109 | |
110 | */
111 |
112 | 'lottery' => [2, 100],
113 |
114 | /*
115 | |--------------------------------------------------------------------------
116 | | Session Cookie Name
117 | |--------------------------------------------------------------------------
118 | |
119 | | Here you may change the name of the cookie used to identify a session
120 | | instance by ID. The name specified here will get used every time a
121 | | new session cookie is created by the framework for every driver.
122 | |
123 | */
124 |
125 | 'cookie' => 'laravel_session',
126 |
127 | /*
128 | |--------------------------------------------------------------------------
129 | | Session Cookie Path
130 | |--------------------------------------------------------------------------
131 | |
132 | | The session cookie path determines the path for which the cookie will
133 | | be regarded as available. Typically, this will be the root path of
134 | | your application but you are free to change this when necessary.
135 | |
136 | */
137 |
138 | 'path' => '/',
139 |
140 | /*
141 | |--------------------------------------------------------------------------
142 | | Session Cookie Domain
143 | |--------------------------------------------------------------------------
144 | |
145 | | Here you may change the domain of the cookie used to identify a session
146 | | in your application. This will determine which domains the cookie is
147 | | available to in your application. A sensible default has been set.
148 | |
149 | */
150 |
151 | 'domain' => env('SESSION_DOMAIN', null),
152 |
153 | /*
154 | |--------------------------------------------------------------------------
155 | | HTTPS Only Cookies
156 | |--------------------------------------------------------------------------
157 | |
158 | | By setting this option to true, session cookies will only be sent back
159 | | to the server if the browser has a HTTPS connection. This will keep
160 | | the cookie from being sent to you if it can not be done securely.
161 | |
162 | */
163 |
164 | 'secure' => env('SESSION_SECURE_COOKIE', false),
165 |
166 | /*
167 | |--------------------------------------------------------------------------
168 | | HTTP Access Only
169 | |--------------------------------------------------------------------------
170 | |
171 | | Setting this value to true will prevent JavaScript from accessing the
172 | | value of the cookie and the cookie will only be accessible through
173 | | the HTTP protocol. You are free to modify this option if needed.
174 | |
175 | */
176 |
177 | 'http_only' => true,
178 |
179 | ];
180 |
--------------------------------------------------------------------------------
/config/sluggable.php:
--------------------------------------------------------------------------------
1 | name;
10 | *
11 | * Or it can be an array of fields, like ("name", "company"), which builds a slug from:
12 | *
13 | * $model->name . ' ' . $model->company;
14 | *
15 | * If you've defined custom getters in your model, you can use those too,
16 | * since Eloquent will call them when you request a custom attribute.
17 | *
18 | * Defaults to null, which uses the toString() method on your model.
19 | */
20 |
21 | 'source' => null,
22 |
23 | /**
24 | * The maximum length of a generated slug. Defaults to "null", which means
25 | * no length restrictions are enforced. Set it to a positive integer if you
26 | * want to make sure your slugs aren't too long.
27 | */
28 |
29 | 'maxLength' => null,
30 |
31 | /**
32 | * If left to "null", then use the cocur/slugify package to generate the slug
33 | * (with the separator defined below).
34 | *
35 | * Set this to a closure that accepts two parameters (string and separator)
36 | * to define a custom slugger. e.g.:
37 | *
38 | * 'method' => function( $string, $sep ) {
39 | * return preg_replace('/[^a-z]+/i', $sep, $string);
40 | * },
41 | *
42 | * Otherwise, this will be treated as a callable to be used. e.g.:
43 | *
44 | * 'method' => array('Str','slug'),
45 | */
46 |
47 | 'method' => null,
48 |
49 | /**
50 | * Separator to use when generating slugs. Defaults to a hyphen.
51 | */
52 |
53 | 'separator' => '-',
54 |
55 | /**
56 | * Enforce uniqueness of slugs? Defaults to true.
57 | * If a generated slug already exists, an incremental numeric
58 | * value will be appended to the end until a unique slug is found. e.g.:
59 | *
60 | * my-slug
61 | * my-slug-1
62 | * my-slug-2
63 | */
64 |
65 | 'unique' => true,
66 |
67 | /**
68 | * If you are enforcing unique slugs, the default is to add an
69 | * incremental value to the end of the base slug. Alternatively, you
70 | * can change this value to a closure that accepts three parameters:
71 | * the base slug, the separator, and a Collection of the other
72 | * "similar" slugs. The closure should return the new unique
73 | * suffix to append to the slug.
74 | */
75 |
76 | 'uniqueSuffix' => null,
77 |
78 | /**
79 | * Should we include the trashed items when generating a unique slug?
80 | * This only applies if the softDelete property is set for the Eloquent model.
81 | * If set to "false", then a new slug could duplicate one that exists on a trashed model.
82 | * If set to "true", then uniqueness is enforced across trashed and existing models.
83 | */
84 |
85 | 'includeTrashed' => false,
86 |
87 | /**
88 | * An array of slug names that can never be used for this model,
89 | * e.g. to prevent collisions with existing routes or controller methods, etc..
90 | * Defaults to null (i.e. no reserved names).
91 | * Can be a static array, e.g.:
92 | *
93 | * 'reserved' => array('add', 'delete'),
94 | *
95 | * or a closure that returns an array of reserved names.
96 | * If using a closure, it will accept one parameter: the model itself, and should
97 | * return an array of reserved names, or null. e.g.
98 | *
99 | * 'reserved' => function( Model $model) {
100 | * return $model->some_method_that_returns_an_array();
101 | * }
102 | *
103 | * In the case of a slug that gets generated with one of these reserved names,
104 | * we will do:
105 | *
106 | * $slug .= $separator + "1"
107 | *
108 | * and continue from there.
109 | */
110 |
111 | 'reserved' => null,
112 |
113 | /**
114 | * Whether to update the slug value when a model is being
115 | * re-saved (i.e. already exists). Defaults to false, which
116 | * means slugs are not updated.
117 | *
118 | * Be careful! If you are using slugs to generate URLs, then
119 | * updating your slug automatically might change your URLs which
120 | * is probably not a good idea from an SEO point of view.
121 | * Only set this to true if you understand the possible consequences.
122 | */
123 |
124 | 'onUpdate' => true,
125 |
126 | ];
127 |
--------------------------------------------------------------------------------
/config/view.php:
--------------------------------------------------------------------------------
1 | [
17 | resource_path('views'),
18 | ],
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Compiled View Path
23 | |--------------------------------------------------------------------------
24 | |
25 | | This option determines where all the compiled Blade templates will be
26 | | stored for your application. Typically, this is within the storage
27 | | directory. However, as usual, you are free to change this value.
28 | |
29 | */
30 |
31 | 'compiled' => realpath(storage_path('framework/views')),
32 |
33 | ];
34 |
--------------------------------------------------------------------------------
/database/.gitignore:
--------------------------------------------------------------------------------
1 | *.sqlite
2 |
--------------------------------------------------------------------------------
/database/factories/ModelFactory.php:
--------------------------------------------------------------------------------
1 | define(App\User::class, function (Faker\Generator $faker) {
16 | static $password;
17 |
18 | return [
19 | 'name' => $faker->name,
20 | 'email' => $faker->unique()->safeEmail,
21 | 'password' => $password ?: $password = bcrypt('secret'),
22 | 'remember_token' => str_random(10),
23 | ];
24 | });
25 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_000000_create_users_table.php:
--------------------------------------------------------------------------------
1 | increments('user_id');
18 | $table->string('first_name', 25)->nullable(false);
19 | $table->string('last_name', 25)->nullable(false);
20 | $table->string('phone', 20)->nullable();
21 | $table->string('email', 45)->nullable(false)->unique();
22 | $table->string('password')->nullable(false);
23 | //$table->string('ip_address', 45)->nullable();
24 | $table->ipAddress('ip_address')->nullable();
25 | $table->enum('role', ['administrator', 'colaborator']);
26 | $table->enum('status', ['active', 'inactive', 'deleted'])->default('active');
27 | $table->rememberToken();
28 | $table->timestamps();
29 | });
30 | }
31 |
32 | /**
33 | * Reverse the migrations.
34 | *
35 | * @return void
36 | */
37 | public function down()
38 | {
39 | Schema::dropIfExists('users');
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_100000_create_password_resets_table.php:
--------------------------------------------------------------------------------
1 | string('email')->index();
18 | $table->string('token');
19 | $table->timestamp('created_at')->nullable();
20 | });
21 | }
22 |
23 | /**
24 | * Reverse the migrations.
25 | *
26 | * @return void
27 | */
28 | public function down()
29 | {
30 | Schema::dropIfExists('password_resets');
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/database/migrations/2017_07_01_203612_create_author_table.php:
--------------------------------------------------------------------------------
1 | engine = 'InnoDB';
17 | $table->increments('author_id');
18 | $table->string('first_name', 25);
19 | $table->string('last_name', 25);
20 | $table->timestamps();
21 | });
22 | }
23 |
24 | /**
25 | * Reverse the migrations.
26 | *
27 | * @return void
28 | */
29 | public function down() {
30 | Schema::drop('author');
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/database/migrations/2017_07_01_203655_create_languages_table.php:
--------------------------------------------------------------------------------
1 | engine = 'InnoDB';
18 | $table->increments('language_id');
19 | $table->string('language_name', 45)->nullable(false);
20 | $table->string('language_code', 2)->nullable(false)->unique();
21 | });
22 | }
23 |
24 | /**
25 | * Reverse the migrations.
26 | *
27 | * @return void
28 | */
29 | public function down()
30 | {
31 | Schema::drop('languages');
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/database/migrations/2017_07_01_203719_create_book_table.php:
--------------------------------------------------------------------------------
1 | engine = 'InnoDB';
18 | $table->increments('book_id');
19 | $table->string('title', 100)->nullable(false);
20 | $table->string('slug', 100)->nullable();
21 | $table->text('description')->nullable();
22 | $table->string('ISBN', 20)->nullable();
23 | $table->smallInteger('pages')->unsigned();
24 | //$table->timestamp('published_at')->useCurrent();
25 | $table->date('published_at')->nullable();
26 | $table->timestamps();
27 |
28 | $table->integer('language_id')->unsigned();
29 | $table->integer('author_id')->unsigned();
30 |
31 | $table->foreign('language_id')
32 | ->references('language_id')
33 | ->on('languages');
34 |
35 | $table->foreign('author_id')
36 | ->references('author_id')
37 | ->on('author')
38 | ->onDelete('cascade');
39 | });
40 | }
41 |
42 | /**
43 | * Reverse the migrations.
44 | *
45 | * @return void
46 | */
47 | public function down()
48 | {
49 | Schema::dropIfExists('book');
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/database/seeds/AuthorTableSeeder.php:
--------------------------------------------------------------------------------
1 | delete(); //delete all records
15 | //App\Models\Book::truncate();
16 | DB::statement('SET FOREIGN_KEY_CHECKS=0;');
17 | App\Models\Author::truncate();
18 | DB::statement('SET FOREIGN_KEY_CHECKS=1;');
19 |
20 | for ($i = 1; $i < 20; $i++) {
21 | DB::table('author')->insert([
22 | 'author_id' => $i,
23 | 'first_name' => str_random(6),
24 | 'last_name' => str_random(6),
25 | //'created_at' => date('Y-m-d H:i:s')
26 | //'created_at' => \Carbon\Carbon::now(),
27 | 'created_at' => \Carbon\Carbon::now()->format('Y-m-d H:i:s')
28 | ]);
29 | }
30 |
31 | }
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/database/seeds/BookTableSeeder.php:
--------------------------------------------------------------------------------
1 | delete(); //delete all records
15 | App\Models\Book::truncate();
16 |
17 | DB::table('book')->insert([
18 | [
19 | 'title' => 'PHP for the Web: Visual QuickStart Guide',
20 | 'slug' => 'php-for-the-web-visual-quickstart-guide',
21 | 'description' => null,
22 | 'ISBN' => '0134291255',
23 | 'pages' => '528',
24 | 'published_at' => '2016-07-09',
25 | 'created_at' => date('Y-m-d H:i:s'),
26 | 'language_id' => 1,
27 | 'author_id' => 1
28 | ],
29 | [
30 | 'title' => 'HTML and CSS: Visual QuickStart Guide',
31 | 'slug' => 'html-and-css-visual-quickstart-guide',
32 | 'description' => null,
33 | 'ISBN' => '0321928830',
34 | 'pages' => '576',
35 | 'published_at' => '2013-08-19',
36 | 'created_at' => date('Y-m-d H:i:s'),
37 | 'language_id' => 1,
38 | 'author_id' => 2
39 | ],
40 | [
41 | 'title' => 'Laravel and AngularJS',
42 | 'slug' => 'laravel-and-angularjs',
43 | 'description' => null,
44 | 'ISBN' => 'B01H0YVS18',
45 | 'pages' => '314',
46 | 'published_at' => '2016-06-12',
47 | 'created_at' => date('Y-m-d H:i:s'),
48 | 'language_id' => 1,
49 | 'author_id' => 1
50 | ],
51 | [
52 | 'title' => 'Restful Web API Design with Node.Js',
53 | 'slug' => 'restful-web-api-design-with-nodejs',
54 | 'description' => null,
55 | 'ISBN' => '1783985860',
56 | 'pages' => '152',
57 | 'published_at' => '2015-11-23',
58 | 'created_at' => date('Y-m-d H:i:s'),
59 | 'language_id' => 1,
60 | 'author_id' => 3
61 | ],
62 | [
63 | 'title' => 'Programmer en JavaScript',
64 | 'slug' => 'programmer-en-javascript',
65 | 'description' => null,
66 | 'ISBN' => '1507139721',
67 | 'pages' => '45',
68 | 'published_at' => '2012-10-04',
69 | 'created_at' => date('Y-m-d H:i:s'),
70 | 'language_id' => 34,
71 | 'author_id' => 5
72 | ],
73 | [
74 | 'title' => 'Démarrer Avec Android Studio',
75 | 'slug' => 'demarrer-avec-android-studio',
76 | 'description' => null,
77 | 'ISBN' => '1633395006',
78 | 'pages' => '293',
79 | 'published_at' => '2016-04-06',
80 | 'created_at' => date('Y-m-d H:i:s'),
81 | 'language_id' => 34,
82 | 'author_id' => 5
83 | ],
84 | [
85 | 'title' => 'Curso de Programación Java',
86 | 'slug' => 'curso-de-programacion-java',
87 | 'description' => null,
88 | 'ISBN' => '1507571178',
89 | 'pages' => '508',
90 | 'published_at' => '2016-02-20',
91 | 'created_at' => date('Y-m-d H:i:s'),
92 | 'language_id' => 27,
93 | 'author_id' => 6
94 | ],
95 | [
96 | 'title' => 'كتاب الأذكياء',
97 | 'slug' => null,
98 | 'description' => null,
99 | 'ISBN' => '9953881146',
100 | 'pages' => '224',
101 | 'published_at' => '2010-02-20',
102 | 'created_at' => date('Y-m-d H:i:s'),
103 | 'language_id' => 6,
104 | 'author_id' => 7
105 | ],
106 | [
107 | 'title' => 'The Laravel Survival Guide',
108 | 'slug' => 'the-laravel-survival-guide',
109 | 'description' => null,
110 | 'ISBN' => '1783985860',
111 | 'pages' => '119',
112 | 'published_at' => '2016-02-20',
113 | 'created_at' => date('Y-m-d H:i:s'),
114 | 'language_id' => 1,
115 | 'author_id' => 1
116 | ],
117 | [
118 | 'title' => 'سلسلة إتقان لتعليم اللغة العربية كتاب الطالب',
119 | 'slug' => null,
120 | 'description' => null,
121 | 'ISBN' => '9957553747',
122 | 'pages' => '224',
123 | 'published_at' => '2015-02-20',
124 | 'created_at' => date('Y-m-d H:i:s'),
125 | 'language_id' => 6,
126 | 'author_id' => 7
127 | ],
128 | [
129 | 'title' => 'Learning React',
130 | 'slug' => 'learning-react',
131 | 'description' => null,
132 | 'ISBN' => 'B01N5GPFM2',
133 | 'pages' => '240',
134 | 'published_at' => '2016-12-27',
135 | 'created_at' => date('Y-m-d H:i:s'),
136 | 'language_id' => 1,
137 | 'author_id' => 9
138 | ],
139 | [
140 | 'title' => 'Typescript Jumpstart',
141 | 'slug' => 'typescript-jumpstart',
142 | 'description' => null,
143 | 'ISBN' => 'B072TQTBKG',
144 | 'pages' => '270',
145 | 'published_at' => '2017-06-17',
146 | 'created_at' => date('Y-m-d H:i:s'),
147 | 'language_id' => 1,
148 | 'author_id' => 9
149 | ],
150 |
151 | ]);
152 | }
153 | }
154 |
--------------------------------------------------------------------------------
/database/seeds/DatabaseSeeder.php:
--------------------------------------------------------------------------------
1 | call(UsersTableSeeder::class);
14 | $this->call(AuthorTableSeeder::class);
15 | $this->call(LanguagesTableSeeder::class);
16 | $this->call(BookTableSeeder::class);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/database/seeds/UsersTableSeeder.php:
--------------------------------------------------------------------------------
1 | delete(); //delete all records
16 | App\Models\Users::truncate();
17 |
18 | for ($i = 0; $i < 20; $i++) {
19 |
20 | $first_name = str_random(6);
21 | $last_name = str_random(6);
22 |
23 | DB::table('users')->insert([
24 | 'first_name' => $first_name,
25 | 'last_name' => $last_name,
26 | 'phone' => mt_rand(200,999).'-'.mt_rand(100,999).'-'.mt_rand(1000,9999),
27 | 'email' => strtolower($first_name . '@domain.com'),
28 | 'password' => bcrypt('1234'),
29 | 'ip_address' => mt_rand(0,255).'.'.mt_rand(0,255).'.'.mt_rand(0,255).'.'.mt_rand(0,255),
30 | 'role' => 'colaborator',
31 | //'created_at' => date('Y-m-d H:i:s')
32 | //'created_at' => \Carbon\Carbon::now(),
33 | 'created_at' => \Carbon\Carbon::now()->format('Y-m-d H:i:s')
34 | ]);
35 |
36 | }
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | include.path=${php.global.include.path}
2 | php.version=PHP_56
3 | source.encoding=UTF-8
4 | src.dir=.
5 | tags.asp=false
6 | tags.short=false
7 | web.root=.
8 |
--------------------------------------------------------------------------------
/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
23 | The master project repository is
24 | https://github.com/halimus/laravel-rest-api
25 |
Click on the links to check simple GET methods whether is working.
27 | 28 |