poorcoder

poorcoder

Member Since 5 Years Ago

istanbul

Experience Points 49,515
Experience Level 10

485 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 834
Lessons
Completed
Best Reply Awards 2
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

31 Dec
1 year ago

poorcoder left a reply on .dev As New GTLD

After google chrome update my all *.dev local sites stop working. I found this blog post maybe help you as well.

https://ma.ttias.be/chrome-force-dev-domains-https-via-preloaded-hsts/

24 Jun
2 years ago

poorcoder left a reply on Replace Element With Jquery

Hi @SerhiiNuzhnyi You have many mistakes on your js codes

$(document).ready(function() { // <= https://developer.mozilla.org/tr/docs/Web/JavaScript/Reference/Statements/block

     $(document).on("click", ".name, .email, .phone, .city", function() {
    // in this scope this means your html document
        $(this).off( "click" ); // this will remove click events on you codument
        $(this).empty();
        $(this).html("<input type='text'>").focus();
    });
});

You should use more specific selectors not => $(document) like => $('.button')

poorcoder left a reply on [Tip] Single App - Multi Dbs And Domains

Hi @matiazar for centralized things like events console mode codes... I say the system "do this with this" I mean when I trigger and event I have to say do this for a.domain.com with this data.

Hi @tprod I am not doing that. On my project all my code base is single no changes needed for any domain... If you have to do that kind of modifications you have to consider not use this kind of solution this will give you big pain when code base grows...

30 Jan
2 years ago

poorcoder left a reply on [Tip] Single App - Multi Dbs And Domains

@codivist In my project was using queue jobs as well. We have one app codebase, so you should figure out which owner app is the owner of that job. I solved that with, every job needs a site key which site owner of this job. I send the key for every job when the events is happening.

I hope I understand you correctly.

21 Dec
2 years ago

poorcoder left a reply on Mobile Apps For Laracast

I am recommending nativescript its fast and native no dom...

25 Oct
2 years ago

poorcoder left a reply on [Tip] Single App - Multi Dbs And Domains

Thanks for the correction @kikvors But I was trying to solve this problem.

My project was a SAAS project. I was trying to be able to use my customers domain names... Customer one : panel.car-dealer.com Customer two : dashboard.book-saler.com

this was the problem I was trying to solve, every new customer just needs to add an A record their dns settings...

Thanks...

02 Aug
3 years ago

poorcoder left a reply on Subdomain + CNAME Routing

@Oyed My solution was solving my problem. My problem was I want to code an application and I don’t want to install my application more than ones, and I want to be able to use different databases for each domain|sub-domain... You can easily modify the database part if you only want to use same database for each domain|sub-domain... My solution works for

my-domain.com
yyy.my-domain.com
xxx.my-domain.com

other-domain.com
y1y1y.other-domain.com
x1x1x.other-domain.com
01 Aug
3 years ago

poorcoder left a reply on Laravel To Mobile App (Android/IOS Platform)

I am developing mobile app with Native Script ( JS + Css + Xml ) mobile application development platform... It's easy to use and understand if you know web technologies...

You can use Laravel as back-end service API and you can develop you application with {NS}

https://www.nativescript.org/about

07 Jul
3 years ago

poorcoder left a reply on Best Way To Store An IP Address (including IPv6)?

It depends on... how you going to use your data? I mean are you going to query this or not?

poorcoder left a reply on How And Where Can Store Images With Laravel?

Use public/images folder...

29 Feb
3 years ago

poorcoder left a reply on Whats The Best Practice To Save These Data

the pivot table can be like this. You can use enum type for days, from, to...

id  | user_id   | days  | from  | to
1   | 1         | Mon   | 09:00 | 22:00
2   | 1         | Tue   | 13:00 | 22:00

Soo you can get user's all days...

20 Jan
3 years ago
17 Jan
3 years ago

poorcoder started a new conversation [Tip] Single App - Multi Dbs And Domains

Hi All,

I am developing a application and... I want to share my solution with you...

Run this in your console

php artisan make:provider MultiAppServiceProvider 

Open your new service provider and replace your boot method on it...

    /**
     * Bootstrap the application services.
     *
     * @throws DomainNotFoundException
     */
    public function boot()
    {
        if ( ! \App::runningInConsole()) {
            $domain = \Request::server('HTTP_HOST');
            $file = str_slug(str_replace('.', '_', $domain), '_') . '.php';

            // if config file not found throw exception and event
            if ( ! file_exists(config_path('sites/') . $file)) {
                $msg = trans('system.domainNotFound');
                //                event(new DomainNotFound); // you can announce an event... 
                throw new DomainNotFoundException($msg);
            }

            // get settings by domain
            $settings = require config_path('sites/') . $file;

            // set all settings by request domain
            foreach (array_keys((array)$settings) as $key) {
                $replace = array_replace_recursive(config($key), $settings[$key]);
                config([$key => $replace]);
            }
        }
    }

Add service provider to app/config/app.php

App\Providers\MultiAppServiceProvider::class,

Create a directory in app/config/sites ...

return [
    // site settings
    'app'      => [
        'site_name'    => 'Site Name',
        'url'          => 'http://example.dev',
        'school_count' => 2,
    ],
    // db settings
    'database' => [
        'default'     => 'mysql',
        'connections' => [
            'mysql' => [
                'driver'   => 'mysql',
                'host'     => 'localhost',
                'database' => 'example_dev',
                'username' => 'root',
                'password' => 'pass',

            ]
        ],
    ],
];

You can add any key, values as you wish...

I hope you like it... Its works for me...

Any comments are appreciated...

Thanks

24 Nov
3 years ago

poorcoder left a reply on Laravel 5.1 - Same Form For Create And Edit Page

You can do like this... You should search for form model binding & route model binding...

create.blade.php

    {!! Form::open(['url' => 'admin/users']) !!}
    <div class="row">
        @include('_form', ['submitButton' => 'Create'])
    </div>
    {!! Form::close() !!}

edit.blade.php

    {!! Form::model($user, ['method' => 'PATCH', 'action' => ['Admin\UsersController@update', $user->id]]) !!}
        <div class="row">
            @include('_form', ['submitButton' => 'Edit'])
        </div>
    {!! Form::close() !!}

_form.blade.php

    <!-- name Form Input -->
    <div class="form-group">
        {!! Form::label('name', 'Name :') !!}
        {!! Form::text('name', null, ['class' => 'form-control']) !!}
    </div>
15 Nov
3 years ago

poorcoder left a reply on Sharing Multiple Images To Social Media

Its not possible in twitter any more Twitter deprecated multi image sharing in their api. for facebook take a look this url https://developers.facebook.com/docs/php/howto/example_batch_upload/5.0.0

19 Oct
3 years ago

poorcoder left a reply on Helper Function Not Working In Config Files

Can you share your get_from_db function...

15 Oct
3 years ago

poorcoder left a reply on Can I Push Data Into A Same Cache Key Into Foreach?

@ericahernandez573 Lets say there is 1000s of messages in $messages and if you loop over them this can be a problem at the future. if you think that the last item is fits for you. you can do something like this...

$messages = collect($messages);
$last = $messages->last();
\Cache::put('another_message', $message->title);

poorcoder left a reply on Can I Push Data Into A Same Cache Key Into Foreach?

You can do this but the last the key "another_message" will have the value of last $message->title!!! The last item will overwrite the pasts...

maybe you can change it like

foreach($messages as $message) {
    \Cache::put('another_message_' . $message->id, $message->title);
}
22 Sep
3 years ago

poorcoder left a reply on Query Builder's Get First, What Am I Doing Wrong?

I think the problem is you are looping cities... when you come to a city data without the lat, lng you get this error...

20 Sep
3 years ago

poorcoder left a reply on How To Get Storage Directory

you can not use storage path like that use public folder instead /public/uploads/myfile.pdf or asset('/public/uploads/myfile.pdf')

poorcoder left a reply on Eloquent Relationships Returning Empty

Album Migration

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAlbumsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('albums', function (Blueprint $table) {
            $table->increments('id');
            $table->string('album_name');
            $table->string('album_image_loc');
            $table->integer('artist_id')->unsigned();
            $table->timestamps();

            $table->foreign('artist_id')
                  ->references('id')
                  ->on('artists');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('albums');
    }
}

Album Model

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Album extends Model
{
    protected $table = 'albums';

    protected $fillable = ['album_name', 'album_image_loc', 'artist_id'];

    public function artist()
    {
        return $this->belongsTo(Artist::class, 'artist_id');
    }
}

Artist Migration

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateArtistsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('artists', function (Blueprint $table) {
            $table->increments('id');
            $table->string('artist_name');
            $table->string('artist_image_loc');
            $table->integer('followers');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('artists');
    }
}

Artist Model

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Artist extends Model
{
    protected $table = 'artists';

    protected $fillable = ['artist_name', 'artist_image_loc', 'followers'];

    public function albums()
    {
        return $this->hasMany(Album::class);
    }
}

migrate your database... php artisan migrate Use tinker php artisan tinker Tinker commands

namespace App;
$artist = Artist::create(['artist_name' => 'Test Artist', 'artist_image_loc' => 'avatar.jpg', 'followers' => 22]);
$album = Album::create(['album_name' => 'Test Album', 'album_image_loc' => 'test_album.jpg', 'artist_id' => 1]);
$album = Album::first();
$album->artist;
24 Jul
4 years ago

poorcoder left a reply on Eloquent Reservation System

How can I make this query ?

SELECT id, title FROM villas where id not in (
SELECT villa_id FROM `reservations` where (`starts_at` between '2015-10-01' and '2015-11-25')
and (`ends_at` between '2015-11-01' and '2016-01-01'))
22 Jul
4 years ago

poorcoder started a new conversation Eloquent Reservation System

Hi all,

I am working on a project but I am stuck on building a reservation system... I need your advise;

My Models are User, Villa, Reservation etc. I need to query empty villas for a date range, and some specs then paginate the result. Can you help me how I can? Thanks.

09 May
4 years ago

poorcoder left a reply on Advanced (?) / Simplified Routes

You should use somthing like this...

example.com/articles/my-first-article
example.com/users/chriss
13 Feb
4 years ago

poorcoder left a reply on Trying To Get Started With Laravel...

take a look this https://gist.github.com/fideloper/7074502 you can ignore some lines or add more ,)

02 Feb
4 years ago

poorcoder left a reply on [Elixir] Gulp --production Not Working?

can you check public/assets/ is writable?

31 Jan
4 years ago

poorcoder started a new conversation Laravel 5 Access Control

I am trying to create a simple user access control mechanism... added a new field on users table as rights(text) for each user you may add values like (users.create,users.show) the middleware splits with comma and controls the url if user has that route in his rights user can see that url otherwise user will be redirect to home.

I hope you like it. Pls give your comments. (sorry for poor english)

Middleware

<?php namespace App\Http\Middleware;

use Closure;
use App\Exceptions\AccessControlException;

class AccessControl {

    /**
     * @param          $request
     * @param callable $next
     *
     * @return mixed
     * @throws AccessControlException
     */
    public function handle($request, Closure $next)
    {
        if (!$this->checkRight($request))
        {
            throw new AccessControlException('You are NOT allowed to see here');
        }

        return $next($request);
    }

    /**
     * @param $request
     *
     * @return mixed
     */
    protected function getUrlName($request)
    {
        return str_replace('/', '.', ltrim($request->getRequestUri(), '/'));
    }

    /**
     * @param $request
     *
     * @return mixed
     */
    protected function getUserRights($request)
    {
    $rights = isset($request->user()->rights) ? $request->user()->rights : '';
        return explode(',', $rights);
    }

    /**
     * @param $request
     *
     * @return bool
     */
    protected function checkRight($request)
    {
        return (bool)in_array($this->getUrlName($request), $this->getUserRights($request));
    }

}

Exception

<?php
namespace App\Exceptions;

use Exception;

class AccessControlException extends Exception {}

Update app/Exceptions/Handler.php

    public function render($request, Exception $e)
    {
            if($e instanceof AccessControlException)
            {
                    return redirect('home')->with('flash_message', $e->getMessage());
            }

        if ($this->isHttpException($e))
        {
            return $this->renderHttpException($e);
        }
        else
        {
            return parent::render($request, $e);
        }
    }

Usage

Route::get('users/show', ['middleware' => 'access', 'uses' => 'HomeController@show']);

poorcoder left a reply on Any Questions About Upgrading To Laravel 5?

@JeffreyWay Thanks for Exception update...

26 Dec
4 years ago

poorcoder left a reply on Where Are You All From?

İstanbul, Turkey

poorcoder left a reply on Htaccess Redirect

I am triyin to exclude some folders from laravel routing.

there is a route I can not change like {catId}/{slug}/{id} and there is a folder and some php codes for creating pdf files public/console/pdfCreator.php and creates some pdf files at public/console/pdf/some.pdf I want to remove console/pdf folder from routing...

I tried like this but did not work.

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # for pdf downloads
     #  RewriteCond $1 !^(console-pdf-converter|console-pdf-converter/pdf) - [L]
     # RewriteCond %{REQUEST_URI} !^/console-pdf-converter
       RewriteRule ^(console-pdf-converter|console-pdf-converter/pdf)($|/) - [L]

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

Thanks for your help :)

poorcoder started a new conversation Htaccess Redirect

I am working a project. They used Laravel but it's very messy... They used Laravel and also structural codes in public folder the second project creates pdf files in public/console/pdf-siles/some.pdf.

And there is a reoute maches for that urls.

How can I set my htaccess ?