Commit d5111e28 by Angel MAS

initial commit

parents
# Package products OneStartup
**onestartup/product** is a module product for websites
# Installation
- Run this in the terminal
```php
composer require onestartup/product
```
- after add the ServiceProvider to the providers array in config/app.php
```php
Onestartup\Product\ProductServiceProvider::class,
```
- Run migration
```php
php artisan migrate
```
- add next lines to app/User.php
```php
public function products()
{
return $this->hasMany('Onestartup\Product\Model\Product', 'user_id');
}
```
- run command for publish views
```php
php artisan vendor:publish --provider="Onestartup\Product\ProductServiceProvider"
```
- run command for publish config file
```php
php artisan vendor:publish --tag=config
```
- run serv
```php
php artisan serve
```
- test in this route how admin user
```php
http://localhost:8000/admin/product/product
```
- add .env vars
```php
SLUG_PRODUCTS=productos
SLUG_PRODUCTS_CATEGORY=categorias
```
- test in this route
```php
http://localhost:8000/portafolio
```
\ No newline at end of file
{
"name": "onestartup/crm-forms",
"description": "manage forms landings",
"type": "library",
"license": "Apache-2.0",
"authors": [
{
"name": "Angel MAS",
"email": "angelmartin.isc@gmail.com"
}
],
"minimum-stability": "dev",
"require": {},
"autoload": {
"psr-4": {"Onestartup\\CrmForms\\": "src"}
}
}
<?php
namespace Onestartup\CrmForms;
use Illuminate\Support\ServiceProvider;
class CrmFormsServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
include __DIR__.'/routes.php';
$this->loadMigrationsFrom(__DIR__.'/migrations');
if (is_dir(base_path() . '/resources/views/vendor/onestartup/crmforms')) {
$this->loadViewsFrom(base_path() . '/resources/views/vendor/onestartup/crmforms', 'crmforms-public');
$this->loadViewsFrom(__DIR__.'/views', 'crmforms');
} else {
$this->loadViewsFrom(__DIR__.'/views', 'crmforms');
$this->loadViewsFrom(__DIR__.'/views/public', 'crmforms-public');
}
$this->publishes([
__DIR__.'/views/public' => resource_path('views/vendor/onestartup/crmforms'),
]);
/*$this->publishes([
__DIR__.'/config/crmforms.php' => config_path('crmforms.php'),
], 'config');*/
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app->make('Onestartup\CrmForms\Controller\CrmFormsController');
$this->mergeConfigFrom( __DIR__.'/config/crmforms.php', 'crmforms');
}
}
<?php
return [
"validate_email" => true,
];
\ No newline at end of file
<?php
namespace Onestartup\CrmForms\Controller;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Requests\RequestInterested;
use App\Http\Controllers\Controller;
use Yajra\Datatables\Datatables;
use App\Notifications\WelcomeInterested;
use App\Notifications\NewInterestd;
use App\Notifications\EmailInvalid;
use App\Interested;
use App\User;
class CrmFormsController extends Controller
{
public function store(RequestInterested $request)
{
$user = User::find(1);
if (config('crmforms.validate_email')) { //Se activa la opcion de validar emails por API
$url = "https://apps.emaillistverify.com/api/verifyEmail?secret=".env('KEY_VERIFY')."&email=".$request->email;
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', $url);
$respuesta = $res->getBody();
if ( $respuesta == 'ok') { //Si el correo es valido
$interested = Interested::create($request->all());
$interested->notify(new WelcomeInterested());
$user->notify(new NewInterestd($interested));
} else { // Si el correo no es valido
$user->notify(new EmailInvalid($request->all()));
return redirect()
->back()
->withInput()
->with('fail', 'fail');
}
} else { // No se valida el correo por api, va directo a la bd
$interested = Interested::create($request->all());
$interested->notify(new WelcomeInterested());
$user->notify(new NewInterestd($interested));
}
return redirect()->route('crmforms.redirect', $request->landing);
}
public function redirect($landing)
{
$view = 'crmforms-public::redirect.'.$landing;
if(view()->exists($view)){ //Si existe una vista con el nombre de la landing dentro de la carpeta public del módulo
return view($view)
->with('registrado', 'registrado')
->with('message_success', 'Hemos recibido tu solicitud, en breve nos comunicaremos contigo');
} else { // Si no, ocupa la vista por default
return view('crmforms-public::redirect.default')
->with('registrado', 'registrado')
->with('message_success', 'Hemos recibido tu solicitud, en breve nos comunicaremos contigo');
}
}
}
<?php
Route::group(['middleware' => ['web', 'auth', 'is_admin']], function(){
/*
Route::delete('delete/cover/category/product/{id}', 'Onestartup\Product\Controller\CategoryController@deleteCover')
->name('delete.cover.category.product');*/
});
Route::group(['middleware' => ['web']], function(){
Route::post('crm/form/store', 'Onestartup\CrmForms\Controller\CrmFormsController@store')->name('crmforms.store');
Route::get('registro/{landing}/exito', 'Onestartup\CrmForms\Controller\CrmFormsController@redirect')->name('crmforms.redirect');
});
{{-- Mensajes de error y mensajes de avisos --}}
@include('partials.messages_partial')
{{-- No remover --}}
{!! Form::open(['route'=> ['crmforms.store'],"method"=>"POST"]) !!}
{!! Form::hidden('landing', (Request::path() != '/' ? Request::path() : 'inicio') ) !!}
@if(isset($_GET["_rdr"]))
{!! Form::hidden('origin', $_GET['_rdr']) !!}
@else
{!! Form::hidden('origin', 'ninguno') !!}
@endif
{{-- *********** --}}
<div class="row">
<div class="col-md-6">
{!! Form::label('name', 'Nombre', ['class'=>'']) !!}
{!! Form::text('name', null, ['class'=>'', 'placeholder'=>'Escribe tu nombre aquí', 'required'=>'required']) !!}
</div>
<div class="col-md-6">
{!! Form::label('email', 'Correo electrónico', ['class'=>'']) !!}
{!! Form::text('email', null, ['class'=>'', 'placeholder'=>'Escribe tu correo aquí', 'required'=>'required']) !!}
</div>
</div>
<div class="row">
<div class="col-md-6">
{!! Form::label('phone', 'Teléfono', ['class'=>'']) !!}
{!! Form::text('phone', null, ['class'=>'', 'id'=>'phone', 'placeholder'=>'Escribe tu teléfono aquí', 'required'=>'required']) !!}
</div>
<div class="col-md-6">
{!! Form::label('extra1', 'Mensaje', ['class'=>'']) !!}
{!! Form::text('extra1', null, ['class'=>'', 'placeholder'=>'Escribe tu mensaje aquí', 'required'=>'required']) !!}
</div>
</div>
<div class="row">
{!! Form::submit('Enviar información', ['class'=>'btn btn-primary']) !!}
</div>
{{-- No remover --}}
{!! Form::close() !!}
{{-- **********] --}}
\ No newline at end of file
@extends('layouts.page-layout')
@section('content')
<h1>Pagina de redireccion por defecto</h1>
@endsection
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit7173633b0cb420d97a2e8a09a0590ba0::getLoader();
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
);
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Onestartup\\Product\\' => array($baseDir . '/src'),
);
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit7173633b0cb420d97a2e8a09a0590ba0
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit7173633b0cb420d97a2e8a09a0590ba0', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit7173633b0cb420d97a2e8a09a0590ba0', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit7173633b0cb420d97a2e8a09a0590ba0::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->register(true);
return $loader;
}
}
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInit7173633b0cb420d97a2e8a09a0590ba0
{
public static $prefixLengthsPsr4 = array (
'O' =>
array (
'Onestartup\\Product\\' => 19,
),
);
public static $prefixDirsPsr4 = array (
'Onestartup\\Product\\' =>
array (
0 => __DIR__ . '/../..' . '/src',
),
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit7173633b0cb420d97a2e8a09a0590ba0::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit7173633b0cb420d97a2e8a09a0590ba0::$prefixDirsPsr4;
}, null, ClassLoader::class);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment