Tetravalence

Tetravalence

Member Since 1 Year Ago

Experience Points
2,820
Total
Experience

2,180 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
20
Lessons
Completed
Best Reply Awards
0
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.

Level 1
2,820 XP
27 Aug
1 year ago

Tetravalence left a reply on One-to-One Relationships

@cmdobueno : It works fine. Thank you.

@abi : thank you for the explanation of how the collections work.

Tetravalence left a reply on One-to-One Relationships

@jlrdw : the simplest queries are OK but chaining queries are not working.

@abi : your chaining query Post::find(1)->details is OK but this one

$collection = $posts->details()->where('post_protected', 'yes')->get();

returns an empty array. The Controller's code is

public function index()
{
   // GET /posts

  $post = new Post;

  $collection = $post->details()->where('post_protected', 'yes')->get();
  dd($collection);
  
  return ...
}      

Then I'm using this when Eloquent's method calls the hasOne method and returns its result.

Tetravalence left a reply on One-to-One Relationships

@Abi: OK but any query returns an empty collection.

Tetravalence left a reply on One-to-One Relationships

@jlrdw: I'm reading just now the Eloquent doc. Any suggestion is appreciated to solve my problem.

Tetravalence started a new conversation One-to-One Relationships

Hello! I'm confused by the whole thing. According to the Eloquent documentation to define the relationship, we place a link method on the Eloquent model but I have troubles getting the formula to get any data. My Post Model is associated with one PostDetail. The relationship one-to-one is defined by the details method in Post

public function details()
{
    return $this->hasOne('Tetravalence\MyPackage\PostDetail', 'post_id');
}

This is the Post migration schema

        Schema::create('posts', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('post_uid', false, true)->default(0);
            $table->text('post_title');
            $table->char('post_type', 20)->default('article');
            $table->char('post_status', 20)->default('draft');
            $table->foreign('post_uid')->references('id')->on('users');
        });

This is the PostDetail migration schema

        Schema::create('post_details', function (Blueprint $table) {
            $table->bigIncrements('post_details_id');
            $table->bigInteger('post_id', false, true);
            $table->longText('post_body');
            $table->char('post_discuss_status', 20);
            $table->timestamp('post_date')->nullable();
            $table->timestamp('post_last_update')->nullable();
            $table->text('post_excerpt');
            $table->char('post_protected', 255);
            $table->bigInteger('post_parent');
            $table->char('post_slug', 255);
            $table->char('post_metakeys', 255);
            $table->foreign('post_id')->references('id')->on('posts');
        });

My query is not working bacause I get an array(0)

        $collection = $posts->details()->where('post_protected', 'yes')->get();

        dd($collection);

What is the correct query to use?

25 Aug
1 year ago

Tetravalence left a reply on Problem With Indentation In Blade Views

@Cronix , @crnkovic : I have to accept the inevitable. Thank you for the your replies!

Tetravalence left a reply on Problem With Indentation In Blade Views

@crnkovic : Laravel 5.4 From Scratch, episode 11, time 12:15

Also in Pass Data to Your Views, Layouts and Structure, Rendering Posts

Tetravalence left a reply on Problem With Indentation In Blade Views

@crnkovic : OK so I should not take care of it but how do Laracasts tutorials come with HTML well indented? They also use ATOM.

Tetravalence left a reply on Problem With Indentation In Blade Views

@crnkovic , @topvillas : Customers do also look at this. Watching video tutorials on Laracasts I have noticed that HTML source code is well indented so the question has arisen spontaneously.

@crnkovic : I'm using language-blade plugin for Atom

Tetravalence started a new conversation Problem With Indentation In Blade Views

Hi! I'm using Atom as IDE for developing Laravel projects but I haven't been able to figure as indentation works out yet. My HTML source code is practically a mess.

Messed Indentation

I have noticed this problem when I use Blade directives as include and extends. How do I fix the indentation?

14 Aug
1 year ago

Tetravalence started a new conversation ErrorException Using Readlink()

Hello, I have an ErrorException that I'd like to handle when readlink() returns false.

public static function validateLink()
{
        $public_resources = public_path().
            '/vendor/'.static::getVendor().'/assets';

        return readlink($public_resources) ?
            $public_resources : false;
}

The failure is an expected behavior so I need the script continues to run after ternary operator. How should I proceed from there?

12 Aug
1 year ago

Tetravalence left a reply on How To Use Auth Middleware In My Own Package

@iambaz You did resolve my problem. Thank you.

Does anyone know why this code below is not working?

Route::middleware('web', 'auth', 'dashboard')->group(function () {
    Route::get('/dashboard', '[email protected]');
    Route::get('/dashboard/template', '[email protected]')->name('template');
});

While this one is correct

Route::group(['middleware' => ['web', 'auth', 'dashboard']], function () {
  Route::get('/dashboard', '[email protected]');
  Route::get('/dashboard/template', '[email protected]')->name('template');
});

Tetravalence left a reply on Problem With Auth Middleware

@crnkovic the Auth middleware does a redirect back to the /home whenever I try to access the /got route even though I'm logged in. The code works fine if added to the main application route routes/web.php but it does not work if added to the package route vendor/tetravalence/mypackage/routes/web.php.

Tetravalence started a new conversation Problem With Auth Middleware

Hi! The following snippet of code taken from a tutorial by Auth0.com

Route::get('/got', [
  'middleware' => ['auth'],
  'uses' => function () {
   echo "You are allowed to view this page!";
}]);

What is that supposed to do? When I log out and I try to access that route, Auth middleware does a redirect back to the/login route, same thing happens when I log in, Auth Middleware does a redirect back to the /home route and the echo message is not displayed. Why?

11 Aug
1 year ago
10 Aug
1 year ago

Tetravalence started a new conversation Assign A Key To Middleware In Package Development

Hello, I'd like to share Middlewares across a group of routes without needing to use their FQN. I know it's possible to assign the Middleware a key in app/Http/Kernel.php but I'm looking for a solution in package development that does not require to change the aforementioned file. Right now I'm using the MyPackageDashboard Middleware by means of his FQN

Route::middleware('auth', Tetravalence\MyPackage\Http\Middleware\MyPackageDashboard::class)->group(function () {
...
// group of routes
});

Where can I set up these keys in package development?

08 Aug
1 year ago

Tetravalence left a reply on Implement Mutiple Themes In A Laravel CMS

@Aleem raised the problem I'm facing with package development. Does anyone know if I have to use a Middleware class to filter any asset used in the active theme? For exemple if current theme does use assets from this directory

/vendor/tetravalence/package/template/current/public/assets/css/style.css

the Middleware should copy style.css into public but I'm not sure if this task can be accomplished in an efficient way. I reject the solution about using artisan command because the user has to active the theme on his own initiative. I would be grateful for any advice you can give me.

06 Aug
1 year ago

Tetravalence left a reply on Subtitles Or Scripts For Lectures...

@bobbybouwmann Edx videos go through automatic speech recognition to produce caption and transcript. They use external service from Cielo24 or 3 Play Media.

29 Jul
1 year ago

Tetravalence left a reply on Subtitles For Tutorials

Any update? I have some difficulty with English listening. Thanks in advance

Tetravalence left a reply on Best Way To Set-up A Package Via Web?

OK this question has been satisfactorily solved using a Service Provider and a global Middleware.

28 Jul
1 year ago

Tetravalence left a reply on Best Way To Set-up A Package Via Web?

@cmdobueno OK, I find your idea really interesting but how should I implement it? Here is my test procedure which is not working, however:

  1. In Mypackage Service Provider I use the app array to inject the middleware into the Kernel in the similar way as it is done in Debug Bar service provider using pushMiddleware method.
  2. The middleware extends CheckForMaintenanceMode class.
  3. The Web route file has the following entry
Route::get('/maintenance', '[email protected]`);

Edit: by using prependMiddleware method now it seems to work but the request is still passed to the parent class CheckForMaintenanceMode after the child class has finished with the request.

26 Jul
1 year ago

Tetravalence started a new conversation Best Way To Set-up A Package Via Web?

Hi, my package needs some records in the tables to work, for example the name of default theme, the e-mail of the site owner, etc. What's the best approach to this? I use a conditional statement in the route file together to a Controller that runs some routine, for example in routes/web.php

if (!file_exists(config_path().'/myapp.php')) {
    Route::get('/', '[email protected]');
} else {
   Route::get('/', '[email protected]');
}

So, if myapp.php file does not exist in config directory then MyApp runs the Web installer. The alternative is to use artisan vendor:publish from command line. Is this the correct way to proceed?

25 Jul
1 year ago

Tetravalence left a reply on Eloquent Model's Created_at And Updated_at Do Not Work

@Sergiu17 Eloquoent's documentation shows this "If you would like to generate a database migration when you generate the model, you may use the --migration or -m option:" then I don't understand what the two constants are supposed to do

Tetravalence started a new conversation Eloquent Model's Created_at And Updated_at Do Not Work

Hello, according to Eloquent documentation if I need to customize the names of the columns used to store the timestamps, I may set the CREATED_AT and UPDATED_AT constants in my model, but this does not seem to work in my application.

<?php

namespace Tetravalence\MyApp;

use Illuminate\Database\Eloquent\Model;

class PostDetail extends Model
{
    const CREATED_AT = 'post_date';

    const UPDATED_AT = 'post_last_update';
...
}

When I run php artisan migrate I still get the default names for the columns. I tried to set the timestamps property on the model to false but it does not work too. Why?

05 Jul
1 year ago

Tetravalence started a new conversation What Is The Difference Between Tag And Provider Option In Vendor:publish Command?

Could someone please explain me the difference between tag and provider option in vendor:publish command issued with php artisan? Does this snippet of code

$this->publishes([
            dirname(dirname(__FILE__)).
                '/config/mypackage.php' => config_path('mypackage.php'),
        ], 'mypackage');

work exactly like this and why?

$this->publishes([
            dirname(dirname(__FILE__)).
                '/config/mypackage.php' => config_path('mypackage.php'),
        ]);
01 Jul
1 year ago

Tetravalence left a reply on Modifying Column Type To BigIncrements Without DBAL Library

@Thyrosis: quite right too but I might need to install the package on, let's say, about twenty sites. I prefer a procedure performed by the package itself . Unfortunately, as you say, any user data is lost and the customer could get angry.

Tetravalence started a new conversation Modifying Column Type To BigIncrements Without DBAL Library

Hello, according to Laravel's documentation in order to modify existing column types, the Doctrine DBAL library has to be installed. Furthermore only certain column types can be "changed". I'm working on a blog package and I need the 'id' column to be bigIncrements instead of increments provided as default in the Laravel migration file for the 'users' table. My solution is to use the Schema facade to drop the 'id' column via 'up' method from migration class of the package, then restore the 'id' column with the new type:

 if (Schema::hasColumn('users', 'id')) {
    Schema::table('users', function (Blueprint $table) {
            $table->dropColumn('id');
                //$table->bigIncrements('id');
        });
        Schema::table('users', function (Blueprint $table) {
                $table->bigIncrements('id')->first();
        });
}

Is this the right way to modify an existing migration without DBAL library? I don't understand because I have to create the 'id' column in a separate Schema block whereas if I try to use dropColumn and bigIncrements methods together then Laravel returns an error message.

15 Jun
1 year ago

Tetravalence left a reply on How To Grab Error Code When .env File Does Not Exist?

@Snapey: OK, now if I run the command php artisan config:cache for deploying my application to production I still get the 500 error message from the server when .env file does not exist in the root of the application directory. So I guess I have overlooked some basic information about the deployment procedure, but what? Thanks for all the replies

11 Jun
1 year ago

Tetravalence started a new conversation How To Grab Error Code When .env File Does Not Exist?

Hello, I would like my package to handle the Laravel request when .env file does not exist in the application directory and the web server sends the 500 error. Should I use both controller and view for this purpose or I have to register an Exception Handler?

05 Apr
1 year ago

Tetravalence left a reply on Defining Middleware

OK, thank you for replying

Tetravalence started a new conversation Defining Middleware

Hello! I'm new to Laravel, sorry for this silly question but I don't understand how/where $request object defines the age public property in "Defining Middleware" guide to Laravel 5.6