Stank0V01

IplexMC at IplexMC

Experience

2,510

0 Best Reply Awards

  • Member Since 3 Months Ago
  • 10 Lessons Completed
  • 0 Favorites

23rd August, 2018

Stank0V01 left a reply on The Requested URL .. Was Not Found On This Server. • 1 month ago

@florent6001 Open /etc/apache2/sites-available and open file 000-default.conf

Replace with that

<VirtualHost *:80>
    #ServerName www.example.com

    ServerAdmin [email protected]
    DocumentRoot /your/path/to/public/dir


    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined


</VirtualHost>

ATTENTION: On documentRoot replace with your public dir!

service apache2 restart

Stank0V01 left a reply on Laravel Dynamic Subdomain Routing To Be Linked To Another Domain Name. • 1 month ago

@Mithrandir Yeah.. i will added it and all will work

22nd August, 2018

Stank0V01 left a reply on The Requested URL .. Was Not Found On This Server. • 1 month ago

Hmm.. The problem must be from apache2 cuz it don't have mod_rewrite.. So go to your terminal and type sudo a2enmod rewrite Then edit /etc/apache2/apache2.conf, changing the "AllowOverride" directive for the /var/www directory (which must be your document root): AllowOverride All

Your config shoud look like that:

# This is the main Apache server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.4/ for detailed information about
# the directives and /usr/share/doc/apache2/README.Debian about Debian specific
# hints.
#
#
# Summary of how the Apache 2 configuration works in Debian:
# The Apache 2 web server configuration in Debian is quite different to
# upstream's suggested way to configure the web server. This is because Debian's
# default Apache2 installation attempts to make adding and removing modules,
# virtual hosts, and extra configuration directives as flexible as possible, in
# order to make automating the changes and administering the server as easy as
# possible.

# It is split into several files forming the configuration hierarchy outlined
# below, all located in the /etc/apache2/ directory:
#
#   /etc/apache2/
#   |-- apache2.conf
#   |   `--  ports.conf
#   |-- mods-enabled
#   |   |-- *.load
#   |   `-- *.conf
#   |-- conf-enabled
#   |   `-- *.conf
#   `-- sites-enabled
#       `-- *.conf
#
#
# * apache2.conf is the main configuration file (this file). It puts the pieces
#   together by including all remaining configuration files when starting up the
#   web server.
#
# * ports.conf is always included from the main configuration file. It is
#   supposed to determine listening ports for incoming connections which can be
#   customized anytime.
#
# * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/
#   directories contain particular configuration snippets which manage modules,
#   global configuration fragments, or virtual host configurations,
#   respectively.
#
#   They are activated by symlinking available configuration files from their
#   respective *-available/ counterparts. These should be managed by using our
#   helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See
#   their respective man pages for detailed information.
#
# * The binary is called apache2. Due to the use of environment variables, in
#   the default configuration, apache2 needs to be started/stopped with
#   /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not
#   work with the default configuration.


# Global configuration
#

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the Mutex documentation (available
# at <URL:http://httpd.apache.org/docs/2.4/mod/core.html#mutex>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
#ServerRoot "/etc/apache2"

#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
#Mutex file:${APACHE_LOCK_DIR} default

#
# The directory where shm and other runtime files will be stored.
#

DefaultRuntimeDir ${APACHE_RUN_DIR}

#
# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars
#
PidFile ${APACHE_PID_FILE}

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 5


# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog ${APACHE_LOG_DIR}/error.log

#
# LogLevel: Control the severity of messages logged to the error_log.
# Available values: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the log level for particular modules, e.g.
# "LogLevel info ssl:warn"
#
LogLevel warn

# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

# Include list of ports to listen on
Include ports.conf


# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

#<Directory /srv/>
#   Options Indexes FollowSymLinks
#   AllowOverride None
#   Require all granted
#</Directory>




# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#
AccessFileName .htaccess

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>


#
# The following directives define some format nicknames for use with
# a CustomLog directive.
#
# These deviate from the Common Log Format definitions in that they use %O
# (the actual bytes sent including headers) instead of %b (the size of the
# requested file), because the latter makes it impossible to detect partial
# requests.
#
# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
# Use mod_remoteip instead.
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.

# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Read the installation guide in doc! Peace!

Stank0V01 started a new conversation Laravel Dynamic Subdomain Routing To Be Linked To Another Domain Name. • 1 month ago

So hello guys.. I have a some question for you.. So i have laravel app that work with subdomain it something like that

{user_site}.myappdomain.com

So its simple.. Users have sites and site its on my subdomain.. So i want users to have ability to linked that domain to their own i mean: {user_site}.myappdomain.com => userdomain.com

So how to do that?? I think with Cname will work! Tell some opinion about the question.. Peace! ;)

18th August, 2018

Stank0V01 left a reply on Getting Monthly Price Sum From Specific Year • 1 month ago

@Abi @Cronix And the price is depend on product price

Orders table:

product_id
user_id

Product table:

id
name
*price

Stank0V01 left a reply on Getting Monthly Price Sum From Specific Year • 1 month ago

@Abi I want when mounth is 0 to give 0 price i mean return to be

[
"01" => "10",
"02"=> "0",
"03" => "0",
etc
etc.
etc.



]

Stank0V01 left a reply on Getting Monthly Price Sum From Specific Year • 1 month ago

bump

Stank0V01 started a new conversation Get All Mounths Revenue! • 1 month ago

Hello guys.. I use that for my chart https://github.com/fxcosta/laravel-chartjs..

I have orders table with that columns

/product_id
/user_id

I have hasMany relationship between Order and Product models

My Order mode:

<?php

namespace App;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;

class Order extends Model
{
    protected $fillable = ['product_id', 'm_c_user_id', 'site_id'];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function user()
    {
        return $this->belongsTo(MCUser::class, 'm_c_user_id');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function product()
    {
        return $this->belongsTo(Product::class);
    }

    /**
     * @return int
     */
    public function getTotalPrice($siteID)
    {

        $orders = self::with('product')->where('site_id', $siteID)->get();
        $total = $orders->sum('product.price');
        return $total;
    }

    /**
     * @return mixed
     */
    public function getTodayTurnover($siteID)
    {
        $orders = self::with('product')->where('site_id', $siteID)->get();
        $total = $orders->where('created_at', '>=', Carbon::today())->sum('product.price');

        return $total;
    }

}

I want to make something like that http://prntscr.com/kk3ude

To get for each mounth total revenue! Please help!

11th August, 2018

Stank0V01 left a reply on Multi Domain Auth Problem! • 2 months ago

smo ;(

Stank0V01 started a new conversation Multi Domain Auth Problem! • 2 months ago

So hello guys.. I have problem with auth.. So lets explain more details!

I have main page mydomain.com and it use default laravel auth.. I have shop page {slug_of_shop}.mydomain.com and auth is only with username.. i have another table for user that not have password column and other things.

So i want to login user on subdomain with only username.. How it will be done that?

My Routes:

<?php

$mainRouter = function () {
    Route::get('/', '[email protected]')->name('home');
    Route::post('/gdpr', '[email protected]');
    Auth::routes();

// Main site cart
    Route::group(['prefix' => 'cart'], function () {
        Route::post('/checkout', '[email protected]')->name('checkout');
        Route::get('/success', '[email protected]')->name('purchaseSuccess');
        Route::get('/failed', '[email protected]')->name('purchaseFailed');
        Route::put('/proccess', '[email protected]')->name('purchase');
        Route::get('/check', '[email protected]')->name('check');
    });

};
Route::group(['domain' => env('PLAIN_URL')], $mainRouter);
Route::group(['domain' => 'www.'.env('PLAIN_URL')], $mainRouter);

// Shop things content
Route::group(['domain' => '{slug}.' . env('PLAIN_URL'), 'middleware' => 'ShopExist'], function () {
    Route::get('/', 'Shop\[email protected]');
    Route::get('/language/{lang}', 'Shop\[email protected]');
    Route::get('/currency/{currency}', 'Shop\[email protected]');
    Route::get('/category/{category}', 'Shop\CategoryCo[email protected]');

    Route::group(['prefix' => 'auth'], function () {
        Route::get('/login','Shop\[email protected]')->middleware('guest');
        Route::get('/logout','Shop\[email protected]')->middleware('auth');
        Route::post('/login','Shop\[email protected]')->middleware('guest');
    });

});

My Shop\AuthController.php

<?php

namespace App\Http\Controllers\Shop;

use App\Http\Controllers\Controller;
use App\Http\Requests\UserCreate;
use App\MCUser;
use App\Setting;
use App\Site;
use Auth;
use Illuminate\Http\Request;

class AuthController extends Controller
{

    public $theme;
    public $site_id;

    /**
     * CategoryController constructor.
     */
    public function __construct(Request $request)
    {
        $site_id = Site::where('slug', $request->route()->parameter('slug'))->first()->id;

        $theme = Setting::where('key', 'theme')->where('site_id', $site_id)->first()->value;

        $this->theme = $theme;
        $this->site_id = $site_id;
    }

    /**
     * @param $user
     */
    private function login($user)
    {
        Auth::login($user);
    }

    /**
     * @param $slug
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function page($slug = null)
    {
        return view('shop.themes.' . $this->theme . '.pages.login');
    }

    /**
     * @param UserCreate $request
     * @return \Illuminate\Http\RedirectResponse
     */
    public function create($slug = null, UserCreate $request)
    {

        $createUser = MCUser::firstOrCreate(
            ['username' => $request->input('username'), 'site_id' => $this->site_id]
        );

        $this->login($createUser);

        return redirect()->to('/');

    }

    /**
     * @return \Illuminate\Http\RedirectResponse
     */
    public function logout()
    {
        Auth::logout();
        return redirect('/');
    }
}

Stank0V01 left a reply on Dynamic SubDomain Issue. • 2 months ago

<?php

$mainRouter = function () {
    Route::get('/', '[email protected]')->name('home');
    Route::post('/gdpr', '[email protected]');
    Auth::routes();

// Main site cart
    Route::group(['prefix' => 'cart'], function () {
        Route::post('/checkout', '[email protected]')->name('checkout');
        Route::get('/success', '[email protected]')->name('purchaseSuccess');
        Route::get('/failed', '[email protected]')->name('purchaseFailed');
        Route::put('/proccess', '[email protected]')->name('purchase');
        Route::get('/check', '[email protected]')->name('check');
    });

};
Route::group(['domain' => env('PLAIN_URL')], $mainRouter);
Route::group(['domain' => 'www.'.env('PLAIN_URL')], $mainRouter);

// Shop things content
Route::group(['domain' => '{slug}.' . env('PLAIN_URL'), 'middleware' => 'ShopExist'], function () {
    Route::get('/', 'Shop\[email protected]');
    Route::get('/language/{lang}', 'Shop\[email protected]');
    Route::get('/currency/{currency}', 'Shop\[email protected]');
    Route::get('/category/{category}', 'Shop\[email protected]page');

    Route::group(['prefix' => 'auth'], function () {
        Route::get('/login','Shop\[email protected]')->middleware('guest');
        Route::get('/logout','Shop\[email protected]')->middleware('auth');
        Route::post('/login','Shop\[email protected]')->middleware('guest');
    });

});

Fixed it with that .

https://stackoverflow.com/questions/34608227/how-to-exclude-www-from-dynamically-created-subdomain

Stank0V01 started a new conversation Dynamic SubDomain Issue. • 2 months ago

Hello, guys.. so i have problem with dynamic subdomain routing! So here is my web.php

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::group(['domain' => env('PLAIN_URL')], function () {
    Route::get('/', '[email protected]')->name('home');
    Route::post('/gdpr', '[email protected]');
    Auth::routes();

// Main site cart
    Route::group(['prefix' => 'cart'], function () {
        Route::post('/checkout', '[email protected]')->name('checkout');
        Route::get('/success', '[email protected]')->name('purchaseSuccess');
        Route::get('/failed', '[email protected]')->name('purchaseFailed');
        Route::put('/proccess', '[email protected]')->name('purchase');
        Route::get('/check', '[email protected]')->name('check');
    });

});

// Shop things content
Route::group(['domain' => '{slug}.' . env('PLAIN_URL'), 'middleware' => 'ShopExist'], function () {
    Route::get('/', 'Shop\[email protected]');
    Route::get('/language/{lang}', 'Shop\[email protected]');
    Route::get('/currency/{currency}', 'Shop\[email protected]');
    Route::get('/category/{category}', 'Shop\[email protected]');

    Route::group(['prefix' => 'auth'], function () {
        Route::get('/login','Shop\[email protected]')->middleware('guest');
        Route::get('/logout','Shop\[email protected]')->middleware('auth');
        Route::post('/login','Shop\[email protected]')->middleware('guest');
    });

});


So when i try www.mydomain.com it not work work only with my main domain mydomain.com But when i add www to first route group it again not work :/

10th August, 2018

Stank0V01 started a new conversation New Session Per Subdomain! • 2 months ago

Hello im tryna make one auth session per domain! So here is more details.

I want to make something like that:

https://ultranetwork.buycraft.net http://ownagepe.buycraft.net/

All of that sites have own session and when loggin in in one of it in another site you must loggin in again. So here is my routes

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::group(['domain' => env('PLAIN_URL')], function () {
    Route::get('/', '[email protected]')->name('home');
    Route::post('/gdpr', '[email protected]');
    Auth::routes();

// Main site cart
    Route::group(['prefix' => 'cart'], function () {
        Route::post('/checkout', '[email protected]')->name('checkout');
        Route::get('/success', '[email protected]')->name('purchaseSuccess');
        Route::get('/failed', '[email protected]')->name('purchaseFailed');
        Route::put('/proccess', '[email protected]')->name('purchase');
        Route::get('/check', '[email protected]')->name('check');
    });

});

// Shop things content
Route::group(['domain' => '{slug}.' . env('PLAIN_URL'), 'middleware' => 'ShopExist'], function () {
    Route::get('/', 'Shop\[email protected]');
    Route::get('/language/{lang}', 'Shop\[email protected]');
    Route::get('/currency/{currency}', 'Shop\[email protected]');
    Route::get('/category/{category}', 'Shop\[email protected]');

    Route::group(['prefix' => 'auth'], function () {
        Route::get('/login','Shop\[email protected]')->middleware('guest');
        Route::get('/logout','Shop\[email protected]')->middleware('auth');
        Route::post('/login','Shop\[email protected]')->middleware('guest');
    });

});


My Session.php config

<?php

return [


    'driver' => env('SESSION_DRIVER', 'database'),


    'lifetime' => env('SESSION_LIFETIME', 120),

    'expire_on_close' => true,


    'encrypt' => true,


    'files' => storage_path('framework/sessions'),


    'connection' => null,


    'table' => 'sessions',


    'store' => null,


    'lottery' => [2, 100],


    'cookie' => 'myshopmcsession',


    'path' => '/',


    'domain' => env('PLAIN_URL'),


    'secure' => env('SESSION_SECURE_COOKIE', false),


    'http_only' => true,


    'same_site' => null,

];

So when you loggin in in one site to not log you in another!

Stank0V01 left a reply on Pass Variable To AppServiceProvider • 2 months ago

I fixed it with called Route facade !

Code:

$site_slug = Route::current()->parameter('slug');

P.S

Don't forget to add "use" use Illuminate\Support\Facades\Route;

Stank0V01 started a new conversation Pass Variable To AppServiceProvider • 2 months ago

Hello, i have problem with passing variable to AppServiceProvider.

So here is what i want:

First my routes:

<?php

Route::group(['domain' => env('PLAIN_URL')], function () {
    Route::get('/', '[email protected]')->name('home');
    Route::post('/gdpr', '[email protected]');

// Main site cart
    Route::group(['prefix' => 'cart'], function () {
        Route::post('/checkout', '[email protected]')->name('checkout');
        Route::get('/success', '[email protected]')->name('purchaseSuccess');
        Route::get('/failed', '[email protected]')->name('purchaseFailed');
        Route::put('/proccess', '[email protected]')->name('purchase');
        Route::get('/check', '[email protected]')->name('check');
    });

});

// Shop things content
Route::group(['domain' => '{slug}.' . env('PLAIN_URL'), 'middleware'=>'ShopExist'], function () {
    Route::get('/','Shop\[email protected]');
});

Auth::routes();

So when someone call {slug}.mydomain.com i want slug to my service provider. Please help! Thanks..

P.S

I try with request()->get() and many other ways.. But service provider is loaded before request procceed

Stank0V01 started a new conversation Provide Custom Variable To Main DatabaseSeeder And Give It To My Seeders • 2 months ago

Hello, someone can give me some example how to provide custom variable to my database seeder and then to give it on my custom seeder!

I want smth like this:

<?php

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run($my_custom_variable_from_model_for_example)
    {
        $this->call(SettingsTableSeeder::class, $my_custom_variable_from_model_for_example);
    }
}

Help.. Thanks!

26th July, 2018

Stank0V01 left a reply on HasMany Relation Ship, To Get Data From One To One Relation Model • 2 months ago

I fixed it with that https://laravel.com/docs/5.5/eloquent-relationships#eager-loading,

here what i make:

Order.php
    public function getTotalPrice() {

        $orders = self::with('product.sms')->get();
        $total = $orders->pluck('product.sms')->sum('price');
        return $total;
    }

Stank0V01 started a new conversation HasMany Relation Ship, To Get Data From One To One Relation Model • 2 months ago

Hello i have 3 tables, so here it

sms\
:id
:price
:servID

Product\
:id
:name
:sms_id
:description

Orders\
:id
:product_id
:user_id

What i want i want to get all products from orders and sum price of product (it depend ot sms price so i use sms_id in product, i call it like this $product->sms->price)

How this will be done?

Here is my models:

class Product extends Model
{
    protected $fillable = [];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function orders(){
        return $this->hasMany(Order::class);
    }
    public function sms() {
        return $this->hasOne(Sms::class,'id','sms_id');
    }

}

class Orders extends Model 
{
    public function product() {
        return $this->belongsTo(Product::class);
    }
}

class Sms extends Model
{
    public function product() {
        return $this->belongsTo(Product::class);
    }
}


23rd July, 2018

Stank0V01 started a new conversation Get Name From Second Table (belongsTo RelationShip) • 2 months ago

Hello guys, i have problem with displaying data from second table! So here is my db structure first:

category:
\id
\name
\parent_id
\vissible

notifications:
\id
\title
\content

category_notification:
\category_id
\notification_id

Model examples

Notification model:

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function categories() {
        return $this->belongsToMany(Category::class,'category_notification');
    }


Category model:

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
     */
    public function notifications() {
        return $this->belongsToMany(Notification::class);
    }

My code:

$notifications = Notification::with('categories')->get();

foreach($notifications as $nft) {

 echo $nft->name.'<br>'.$nft->categories-title

}

What im doing wrong?

19th July, 2018

Stank0V01 left a reply on Array To String Conversion On One To One Relation Ship ERROR! • 2 months ago

Oh, boys. It was from protected $table = ['sms'] I make it to protected $table = 'sms' and all works fine! :)

Stank0V01 left a reply on Array To String Conversion On One To One Relation Ship ERROR! • 2 months ago

I call it like this $var = Product::find(1); $var->sms

Stank0V01 left a reply on Array To String Conversion On One To One Relation Ship ERROR! • 2 months ago

My tables:

products: \id \name \desc \sms_id

sms: \id \text \number \servID

18th July, 2018

Stank0V01 started a new conversation Array To String Conversation On One To One Relation Ship! • 2 months ago

Hello guys, i have a problem with one to one relationship! When i make it it give that error

 Array to string conversion in D:/laragon/www/ishop-bg/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php on line 63

Here is my model

Product.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Product extends Model
{
    protected $fillable = [];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function sms() {
        return $this->hasOne(Sms::class,'sms_id');
    }
}
Sms.php

17th July, 2018

Stank0V01 started a new conversation How To Make Active Class When It Have Sub Category? • 2 months ago

Hello guys im tryna to make active class when is clicked on subcategory

            <div class="collapse navbar-collapse">
                <ul class="nav navbar-nav">
                    <li class="{{ isActive('/') }}"><a href="{{ url('/') }}"><b class="fa fa-home"></b> @lang('messages.home')</a></li>
                    @foreach ($categories as $cat)
                        <li class="{{ $cat->children->count() > 0 ? 'dropdown' : ''}} {{ isActive('/category/'.$cat->slug) }}">
                            <a href="{{ url('/category/'.$cat->slug) }}" class="{{ $cat->children->count() > 0 ? 'dropdown-toggle' : ''  }}"
                               data-toggle="{{ $cat->children->count() > 0 ? 'dropdown' : ''  }}">
                                {{$cat->name}} {!! $cat->children->count() > 0 ? '<b class="fa fa-caret-down"></b>' : '' !!}
                            </a>
                            <ul class="dropdown-menu">
                            @foreach($subcategories as $sub)
                                @if($sub->parent_id == $cat->id)
                                        <li><a href="{{ url('category/'.$sub->slug) }}">{{ $sub->name }}</a></li>
                                @endif
                            @endforeach
                            </ul>
                         </li>
                    @endforeach
                </ul>
            </div>

How it will be done (isActive function is my custom helper that i make here it is)

<?php
if(!function_exists("isActive")) {
    /**
     * @param $url
     * @return string
     */
    function isActive($url) {
        return $_SERVER['REQUEST_URI'] == $url ? 'active' : '';
    }
}

16th July, 2018

Stank0V01 left a reply on Eloquent, Make Items Upgradable • 2 months ago

ok

Stank0V01 left a reply on Eloquent, Make Items Upgradable • 2 months ago

@topvillas Can explain what current i must do?

Stank0V01 left a reply on Eloquent, Make Items Upgradable • 2 months ago

I don't think that? :D i just want some answear like all users here

Stank0V01 left a reply on Eloquent, Make Items Upgradable • 2 months ago

So now can i bump?

15th July, 2018

Stank0V01 left a reply on Eloquent, Make Items Upgradable • 3 months ago

@Cronix , ok i sorry, so someone give me smth about question

Stank0V01 left a reply on Eloquent, Make Items Upgradable • 3 months ago

bump

Stank0V01 started a new conversation Eloquent, Make Items Upgradable • 3 months ago

Hello i have some idea to ranks be upgradable! So i have categories products and orders!

So i want to make something like this

First i will give you some code and migrations:

Product structure:

        Schema::create('products', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('description');
            $table->unsignedInteger('recommended');
            $table->integer('price');
            $table->string('image');
            $table->unsignedInteger('required_product_id')->nullable();
            $table->unsignedInteger('max_buys');
            $table->integer('discount')->nullable();
            $table->timestamps();
        });

Orders structure:

        Schema::create('orders', function (Blueprint $table) {
            $table->increments('id')->unique();
            $table->integer('product_id');
            $table->integer('user_id');
            $table->timestamps();
        });

So i will explain what column : required_product_id column must have id of product that must purchase first to purchase it! Second is max_buys

if max_buys is 1 product can be buyable only once , if its 0 it can purchased many times that i want.

If you want some example: http://iplexmc.eu/p/1 (It will ask you for username enter some random username and click here http://prntscr.com/k6qzby

(All products are in only category so it is hasMany rel)

CategoriesController.php

namespace App\Http\Controllers;

use App\Product;
use Illuminate\Http\Request;
use App\Category;
use App\User;
use App\Order;
use Illuminate\Support\Facades\DB;

class CategoriesController extends Controller
{
    /**
     * @param Category $category
     * @param User $user
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function showProducts(Category $category, User $user)
    {
        $products = $category->products();


        return view('products.category',['extras'=>$extras]);


    }
}

Please help me , i don't know how to do that (I want products var to return and producta that be only once purchased) (When user purchase rank that is onlyOnce it will removed from the list)

Stank0V01 left a reply on Laravel Paypal IPN • 3 months ago

@nnayeem no!

Stank0V01 left a reply on Check Product Is Purchased , To Unlock Next One! • 3 months ago

I fuck'up my brain :D with that query :d i thinking to not make it with upgrades @Tray2 Its way easy to use eloquent so for that i use laravel

Stank0V01 left a reply on UNION MySQL, Check If Its Bold • 3 months ago

bump

Stank0V01 started a new conversation UNION MySQL, Check If Its Bold • 3 months ago

Stank0V01 left a reply on Check Product Is Purchased , To Unlock Next One! • 3 months ago

It not work with DISTINCT

SELECT p.* FROM products p WHERE required_product_id IS NULL 
UNION 
SELECT  p.* FROM products p, orders o WHERE p.required_product_id = o.product_id 
AND o.user_id = 1
UNION DISTINCT
SELECT p.`*` FROM products p, orders o WHERE p.id NOT IN (SELECT product_id FROM orders WHERE product_id = p.id AND o.user_id = 1)
AND p.max_buys = 1;

http://prntscr.com/k6od0q @Tray2

Stank0V01 left a reply on Check Product Is Purchased , To Unlock Next One! • 3 months ago

:D Now the most hard thing is how to make not row duplicate

Stank0V01 left a reply on Check Product Is Purchased , To Unlock Next One! • 3 months ago

@Tray2 it get syntax error on last where

Stank0V01 left a reply on Check Product Is Purchased , To Unlock Next One! • 3 months ago

SELECT p.* FROM products p WHERE required_product_id IS NULL 
UNION ALL
SELECT p.* FROM products p, orders o WHERE p.required_product_id = o.product_id 
AND o.user_id = 1
UNION ALL
SELECT p.* FROM products p, orders o WHERE p.max_buys = 0

I make that query but it return that

http://prntscr.com/k6o065

Stank0V01 left a reply on Check Product Is Purchased , To Unlock Next One! • 3 months ago

So sql must be that

@Tray2


SELECT p.* from Products p where required_product_id IS NULL 

UNION ALL

SELECT p.* FROM products p orders o WHERE p.required_product_id = o.product_d
AND o.user_id = 1 

UNION ALL

SELECT p.* FROM products p where p.max_buys = 1 

Stank0V01 left a reply on Check Product Is Purchased , To Unlock Next One! • 3 months ago

Ok, but i have problem with supplied can you give me query? Cuz i have table and union is might difficult to understand to me @Tray2

Stank0V01 left a reply on Check Product Is Purchased , To Unlock Next One! • 3 months ago

Products: http://prntscr.com/k6mbx4, Orders: http://prntscr.com/k6mbzv only_once: http://prntscr.com/k6mc1p

So when user buy the rank current purchased rank to remove from list and display anotherone but if onlyOnce is set to N current purchased rank to not remove from list!

@Tray2

14th July, 2018

Stank0V01 left a reply on Check Product Is Purchased , To Unlock Next One! • 3 months ago

I hope tommorow u will help mu cuz i very need that option to added in my site

Stank0V01 left a reply on Check Product Is Purchased , To Unlock Next One! • 3 months ago

SELECT p.*, "Y", onlyOnce
  FROM products p 
  WHERE required_product IS NULL 
  UNION ALL
  SELECT p.*, "Y", onlyOnce
  FROM products p, orders o 
  WHERE p.required_product = o.product_id 
  AND o.user_id = 1 UNION ALL
SELECT p.* , "onlyOnce","Y"
FROM products p, orders o, only_once once
WHERE p.required_product = o.product_id
AND p.id = once.product_id
AND p.id NOT IN (SELECT product_id FROM orders WHERE o.product_id = p.id and o.user_id=1) 

I change it to that cuz my colum onlyOnce in products must be Y/N and i make another table called only_once with user and product_id but i have problem it display same thing like before? :D if i add in orders it will unlock next and not hide current ;( i want to make it purchasable only once

Stank0V01 left a reply on Check Product Is Purchased , To Unlock Next One! • 3 months ago

@Tray2 i change it to this way:

       $extras = DB::select(

            'SELECT p.*
  FROM products p 
  WHERE required_product IS NULL 
  UNION ALL
  SELECT p.* 
  FROM products p, orders o 
  WHERE p.required_product = o.product_id 
  AND o.user_id =' .  $user->id .  'UNION ALL
  SELECT p.* , "onlyOnce" product_type
  FROM products p, orders o, only_once on 
  WHERE p.required_products = o.product_id
  AND p.id = on.product_id 
  AND p.id NOT IN (SELECT product_id FROM orders WHERE o.product_id = p.id and o.user_id ='.$user->id);

Still return that:

http://9af1104f.ngrok.io

I give u my host link to check what it come from

Stank0V01 left a reply on Check Product Is Purchased , To Unlock Next One! • 3 months ago

@Tray2 hhttp://prntscr.com/k6hsut This is my table

This is my changed code

        $extras = DB::select(

            'SELECT p.*
  FROM products p 
  WHERE required_product IS NULL 
  UNION ALL
  SELECT p.* 
  FROM products p, orders o 
  WHERE p.required_product = o.product_id 
  AND o.user_id =' .  $user->id .  'UNION ALL
  SELECT p.* , "onlyOnce" product_type
  FROM products p, orders o, only_once on 
  WHERE p.required_products = o.product_id
  AND p.id = on.product_id 
  AND p.id NOT IN (SELECT "x" FROM orders WHERE o.product_id = p.id and o.user_id ='.$user->id);

What im doing wrong cuz it give me error?

Stank0V01 left a reply on Check Product Is Purchased , To Unlock Next One! • 3 months ago

@Tray2 I must do it like this

|id|name|desc|bla|bla|product_type 1 name desc .... .... HERE WHAT ?

Stank0V01 left a reply on Check Product Is Purchased , To Unlock Next One! • 3 months ago

Hm.. Im not sure i can understand that part @Tray2 can you explain more details? Where i must create column cuz if not in my tables where it must be? :D

Stank0V01 left a reply on Check Product Is Purchased , To Unlock Next One! • 3 months ago

@Tray2 it say it have syntax error! And where is placeholder column?

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.