papa

Member Since 3 Years Ago

Experience Points 8,745
Experience Level 2

1,255 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 29
Lessons
Completed
Best Reply Awards 5
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.

01 Jul
1 month ago

papa left a reply on Laravel Mix With Vue-loader

@BOBBYBOUWMANN - No the error was in my Login.vue file. I use VeeValidate and I should firstly use it

Vue.use(require('vee-validate'));

in my app.js file.

Also I did not know that Mix already use vue-loader so I removed also the webpackConfig which I have posted above.

Thanks

papa left a reply on Laravel Mix With Vue-loader

@JEFFREYWAY - ok thanks let me check, i guess is the problem in my component Login.vue

papa left a reply on Laravel Mix With Vue-loader

@BOBBYBOUWMANN -

window.Vue = require('vue');

// const files = require.context('./', true, /\.vue$/i);
// files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default));

Vue.component('login-form', require('./components/Login.vue').default);


const app = new Vue({
    el: '#app',
    mounted() {
        console.log('asd');
    }
});

papa started a new conversation Laravel Mix With Vue-loader

I try to use vue-loader with webpack.mix.js without success

My configuration

const mix = require('laravel-mix');
const VueLoaderPlugin = require('vue-loader/lib/plugin');

mix
    .webpackConfig({
        module: {
            rules: [
                {
                    test: /\.vue$/,
                    loader: 'vue-loader'
                }
            ]
        },
        plugins: [
            new VueLoaderPlugin()
        ]
    })
    .js('resources/js/app.js', 'public/js')
    .extract(['vue', 'vee-validate'])
;

The error I get is

Error: [VueLoaderPlugin Error] No matching use for vue-loader is found.
Make sure the rule matching .vue files include vue-loader in its use.

Some support!

30 May
2 months ago

papa started a new conversation Laravel Echarts With WebWorker

I have developed a new package for Laravel Echarts.

Feel free to test it and give a feedback for improvements.

Under Github the repository and on packagist

https://github.com/apapazisis/laracharts https://packagist.org/packages/apapazisis/laravel-echarts

02 May
3 months ago

papa left a reply on Documenting Your New Project

@zetecvan JIRA Confluence and Ticketing system maybe

15 Apr
4 months ago

papa left a reply on Extract Only Useful CSS Files/rules And JS Code

You can merge all your css files in one file and the same for js files

12 Apr
4 months ago

papa left a reply on Dealing With Huge Tables And Pagination

@spacedog4

Do you use the Datatables plugin with ajax calls?

papa left a reply on How To 'compose' The Route Definitions?

@realtebo

One think that you can do in web.php file is this

foreach(File::allFiles(__DIR__.'/web') as $file) {
    require $file->getPathname();
}

where in web folder you have multiple files of routes

A second option is to add some code in RouteServiceProvider

as an example

protected function mapModuleRoutes()
    {
        foreach ($this->modules as $module) {
            if (file_exists(app_path('Modules/' . $module .'/routes.php'))) {
                Route::middleware('web')
                    ->namespace($this->namespace)
                    ->group(app_path('Modules/'. $module . '/routes.php'));
            }
        }
    }

Here I have modular structure and each module has its routes.php file

10 Apr
4 months ago

papa left a reply on Custom Collections In Child Models

@ Yes, you may create RepositoryClass for Refill, Car e.t.c. and from their you can add methods to get your data

papa left a reply on Custom Collections In Child Models

@placeholdermeme

Yes, I think is beautiful to do

$car->getAverageMpgByMonth() 


public function getAverageMpgByMonth()
{
    return $this->refills()->avg();   // or you can use here foreach refills()
}

papa left a reply on Question About View Sharing

You can use in your ServiceProvider

public function boot()
    {
        // Share User details to all view
        View::composer('*', function($view) {
                $view->with('user', Auth::user());
        });
}

Just add your code

papa left a reply on Custom Collections In Child Models

refills() will return you a collection of many. Thus you can not do it.

Think about https://laravel.com/docs/5.8/collections#method-average

or

$car->avgRefills()

and in Car model

public function avgRefills()
{
    return $this->refills()->avg();   // or you can use here foreach refills()
}
08 Apr
4 months ago

papa left a reply on Applying Design Patterns In Laravel

Think about Strategy and Factory Patterns

class PaymentFactory
{
    private $payments = [
        'paypal' => PayByPaypal::class
    ];

    public function createPaymentObject(string $payment)
    {
        $paymentClass = $this->payments[$payment];

        if (class_exists($paymentClass)) {
            return new $paymentClass;
        }

    // exception
    }
}

trait PaymentTrait
{
    protected $paymentsTypes = [
        'paypal' => 'Paypal'
    ];

    public function getPaymentTypes(): array
    {
        return $this->paymentsTypes;
    }
}

interface PaymentStrategy
{
    public function pay($config);   
}

abstract class PaymentBase implements PaymentStrategy
{
    public function pay($config)
    {
        return $this->doPay($config);
    }
    
}

class PayByPayPal extends PaymentBase
{
    public function doPay($config)
    {
        // here you will implement the PayPal API
    }
}

class PaymentController extends Controller
{
    public function pay(Request $request)
    {
    $config = Config::get('payments.paypal');
        Session::put('payment', $request->input('payment'));

        return ((new PaymentFactory())->createPaymentObject($request->input('payment')))->pay($config);
    }
}

You can use the Trait to get the payments in the front end

papa left a reply on Applying Design Patterns In Laravel

Imagine you have a Controller

class MyController extends Controller
{
    protected $userService;

    public function __construct(
        UserServiceInterface $userService
    )
    {
        $this->userService = $userService;
    }
    public function index()
    {
        return view('test')->with(
            'user' => $this->userService->getUser()
        )
    }
}

interface userServiceInterface
{
    public function getUser();
}
class userService implement userServiceInterface
{
    public function getUser()
    {
        return Auth::user();
    }
}

class UserServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->bind(UserServiceInterface::class, UserService::class);
    }
}


The same classes for Repository: 
    UserService => UserRepository
    UserServiceInterface => UserRepositoryInterface

Then the controllers call  services which call repositories to get data

papa left a reply on Applying Design Patterns In Laravel

First think about using Service Layer Design Pattern and Repository Design Pattern with Constructor Dependency Injection.

22 Mar
4 months ago

papa left a reply on Test Validation Email Unique Fails Always

@tykus found it

should change the sequence between the validation and the registration

foreach ($users as $user) {
            $validator = Validator::make($user, (new UserRequest())->rules();
            $this->assertEquals(false, $validator->fails()); // $this->assertTrue($validator->passes());

            $response = $this->post(route('doRegister'), $user);

I apologize if you have found my comment offensive, it was not like that. Thanks for your support.

papa left a reply on Test Validation Email Unique Fails Always

@tykus Firstly: of course the $this->id is not set and is null and the rules() are

return [
            'firstName' => ['required'],
            'lastName' => ['required'],
            'email' => ['required', 'email', 'unique:User,email,null,id'],
            'password' => ['required', 'min:6', 'confirmed'],
            'password_confirmation' => ['min:6'],
            'address' => ['required'],
            'zipcode' => ['required'],
            'city' => ['required'],
            'phone' => ['required'],
            'language' => ['required']
        ];

Secondly: this Rule::unique('User')->ignore($this-id) is the same with this 'unique:User,email,null,id'. I have both tested.

Third: A feature test should be testing your application code, not the framework. Where I test the framework??

21 Mar
4 months ago

papa left a reply on Test Validation Email Unique Fails Always

What I get in log file local.INFO: {"email":["validation.unique"]}

papa left a reply on Test Validation Email Unique Fails Always

@TYKUS - Yes all my tables starts with capital letter

papa started a new conversation Test Validation Email Unique Fails Always

The Request

public function rules()
    {
        $id = (isset($this->id) ? $this->id : null) . ',id';

        return [
            'firstName' => ['required'],
            'lastName' => ['required'],
            'email' => ['required', 'email', 'unique:User,email,' . $id],
            'password' => ['required', 'min:6', 'confirmed'],
            'password_confirmation' => ['min:6'],
            'address' => ['required'],
            'zipcode' => ['required'],
            'city' => ['required'],
            'phone' => ['required'],
            'language' => ['required']
        ];
    }

The test Function

public function testUser()
{

$users = [
            [
                'firstName' => 'Name',
                'lastName' => 'Surname',
                'password' => 123456,
                'password_confirmation' => 123456,
                'address' => 'My address',
                'zipcode' => '84763',
                'city' => 'New York',
                'email' => '[email protected]',
                'phone' => '017654875674',
                'mobile' => '763636',
                'language' => 1
            ],
        ];


 foreach ($users as $user) {
            $response = $this->post(route('doRegister'), $user);

            $validator = Validator::make($user, $validation->rules());
            $this->assertEquals(false, $validator->fails());

            $this->assertDatabaseHas('User', ['email' => $user['email']]);
            $this->assertDatabaseHas('Member', [
                'firstName' => $user['firstName'],
                'lastName' => $user['lastName'],
                'address' => $user['address'],
                'zipcode' => $user['zipcode'],
                'city' => $user['city'],
                'phone' => $user['phone'],
                'mobile' => $user['mobile'],
                'langId' => 1
            ]);

            $response->assertRedirect(route('index', 200));
        }
}

The $validator gives me always error on Email Unique Rule and the test does not pass. Have someone an idea why that happens?

01 Dec
8 months ago

papa left a reply on How To Pass Dynamic Selector Value To Jquery

@nonanovi just type in your html

<select data-id="your_dynamic_id">

and in jQuery

var id = $(this).data("id")

16 Nov
9 months ago

papa started a new conversation Does Envoyer CI And CD Both?

Hello Team,

does Envoyer Continuous Integration (CI) and Continuous Deployment (CD) as Jenkins or Circleci does??

For my view it looks that Envoyer idoes only CD and not CI.

24 Sep
1 year ago

papa started a new conversation Service Provider IoC, Bindings Diferrence

I have in my service Provider the following code in register function

use App\Modules\Core\Includes\Services\Human;

public function register() 
{


$this->app->bind('human', 'App\Modules\Core\Includes\Services\Human');
$this->app->bind('human', function() {
    return new Human();
});
}

What is the difference between this two binding ?

12 Sep
1 year ago

papa left a reply on How To Delete A Records Which Its ID Not Exists In Another Tables ?

@bashy yeah I guess something like this.

function deleteUser($id)
{
    // Here the relations to check if exists at least a record
    // of 1 of 10 Tables
}

papa started a new conversation How To Delete A Records Which Its ID Not Exists In Another Tables ?

Hi,

I have a table of users

Users
id, first_name, last_name
1, Tom, Baar

and also I have 10 tables where all of them have a column which is the foreign_key of user_id

e.x.

Contracts
id, name, contract_manager(foreign key of users table)
1, Servers, 1

Logs
id, data, user_id(foreign key of users table)
1, data, 1

My question is how can I check if the user_id who I want to delete exists in one of the 10 tables it is associated so that I prevent the deleteion of the user ?

06 Sep
1 year ago

papa left a reply on SQLSTATE[HY000]: General Error: 1215 Cannot Add Foreign Key Constraint

Schema::create('posts', function (Blueprint $table) {
            $table->increments('id')->unsigned();
        $table->integer('sr')->nullable();


Schema::create('updates', function (Blueprint $table) {
            $table->increments('id');
        $table->integer('sr_id')->unsigned();
        $table->text('update');
            $table->timestamps();
        });

Schema::table('updates', function ($table) {
        $table->foreign('sr_id')->references('id')->on('posts')->onDelete('cascade');
        });

papa left a reply on Laravel Beginner Wants To Become A Full Time

Yes is needed a PHP background and basically an Object-oriented programming. You can start looking about classes and how they collaborate. You can find on google tutorials about PHP and classes. Open an Editor and start typing.

papa left a reply on Localization Set A Locale

@janakaontomatrix you may use also a middleware.

05 Sep
1 year ago

papa left a reply on Creating A New Command

!!!cannot follow!!! @eshaparvathi

papa left a reply on Creating A New Command

@eshaparvathi can you post code...

papa left a reply on None Of My Routes Work Except For The '/' - New Laravel 5.5 Install

It may be a problem of https://laravel.com/docs/5.5#pretty-urls

Also I post you a nginx config you may try..

server {
    listen   80 default_server;

    root /var/www/laravel/public/;
    index index.php index.html index.htm;

    location / {
         try_files $uri $uri/ /index.php$is_args$args;
    }

    # pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
    location ~ \.php$ {
            try_files $uri /index.php =404;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
    }
}

papa left a reply on How To Pass Dynamic Selector Value To Jquery

@bipin think about something like this

   <select class="selectpicker form-control " id="applicantstatus_{{$s->id}}" name="applicantstatus_{{$s->id}}" data-style="btn-info btn btn-xs" data-posttd="{{$s->id}}" data-width="auto" >

 $('.setvalue').on('click', function() {
       var id = $(this).data("id");
       var inp =  $('#applicantstatus_' + id).val();

papa left a reply on None Of My Routes Work Except For The '/' - New Laravel 5.5 Install

@jpeterson579 check if you can open your routes typing localhost/laravel/index.php/myroute

papa left a reply on Error : Internal Server Error

@muazzamazaz It may be your url, try without slash /

url: 'delprofile',
04 Sep
1 year ago

papa left a reply on Custom Message In Validator Laravel 5.5

Try

request()->validate([
            'name' => 'required',
            'id' => 'exists:doc_contractors,id'
        ], [
            'name.required' => 'your message',
            'id.exists' => 'your message'
        ]);

papa left a reply on I Got Suggestions And Errors In Terminal After Creating New Project In Laravel

@archiebango looks ok your output.... try to create a new project and check that out.

papa left a reply on Custom Message In Validator Laravel 5.5

@grupaang

$messages = [
    'email.required' => 'The :attribute field is required.',
];

$validator = Validator::make($input, $rules, $messages);

If you have a Request file then you need to define a function

public function messages()
{
    $messages = [
        'email.required' => 'The :attribute field is required.',
    ];

    return $messages;
}

papa left a reply on 127.0.53.53 When Pining Laravel Project !!!

@Nasr1 as said dont use Chrome and you may change also the tld

papa left a reply on 127.0.53.53 When Pining Laravel Project !!!

@nasr1 127.0.53.53 is a special IPv4 address that will appear in system logs alerting system administrators that there is potential name collision issue, enabling a quick diagnosis and remediation. The "53" is used as a mnemonic to indicate a DNS-related problem owing to the use of network port 53 for the DNS service.

Well, turns out over the last years the number of TLDs (top-level domains) has been expanding. Apart from the original .com, .org, .net, .gov and the like, there's an ever-growing list of generic TLDs. As of the writing of this, there's currently more than a thousand gTLDs.

Guess what are some examples of gTLDs? Words such as "drive", "google", "microsoft", "hotmail", "youtube" and "android". So, when you enter those words on the address bar on Firefox, instead of using it to perform a search on the default search engine, it will first check if it resolves as a domain name.

Thanks to our friends at ICANN, it does resolve to 127.0.53.53. Which means localhost. Your browser is trying to connect to the port 80 of your own computer and, unless you have a web server running, you will see a connection error message.

papa left a reply on Printing Message

@davy_yg Post code to figure it out!

03 Sep
1 year ago

papa left a reply on 1066 Not Unique Table/alias

@qWici you try to implement pivot relatioship

This is not ok. This should be a third table with which Beers and Users are connected. Need to be removed from there.

protected $table = "user_beers_data";

USER MODEL
public function beers()
    {
        return $this->belongsToMany(Beers::class, 'user_beers_data', 'user_id' 'beer_id');
    }
BEER MODEL
public function users()
{
    return $this->belongsToMany(User::class, 'user_beers_data', 'beer_id', 'user_id');
}

papa left a reply on Accessor Not Being Executed

@vkronlein maybe the problem is on === . Check the values of variable $value. Maybe is not the same $value === 'on' or not same datatype $value === 1

papa left a reply on Redirect User To A Route After Registration

@NICKGRAFFIS Why dont you use code like this

return redirect()->route('home');
01 Sep
1 year ago

papa left a reply on Redirect If 404

use Exception;

public function handle($request, Closure $next, Exception $e) {
     
    if(\Auth::user() && \Auth::user()->admin == 1)
            return $next($request);

    if ($e->getStatusCode() == 404) {
        return redirect(\Config::get('app.front_url'));
    }
    
}

not tested but you can try

papa left a reply on Redirect If 404

@Waldemar if not admin you can write abort(404);. Then you can have a 404.blade.php page in resources/views/error folder