Tetravalence

Tetravalence

Member Since 9 Months Ago

Experience Points 2,820
Experience
Level
Lessons Completed 20
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

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

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

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

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

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

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

27 Aug
3 months 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
3 months 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

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.

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
3 months 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.

12 Aug
3 months 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 redirected back to the/login route, same thing happens when I log in, the echo message is not displayed. Why?

11 Aug
4 months ago
10 Aug
4 months 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
4 months 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 would be grateful for any advice you can give me.

06 Aug
4 months 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
4 months 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
4 months 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]`);

Unfortunatly, the application continues to load the 503 default view bypassing my middleware.

26 Jul
4 months 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 installer. The alternative is to use artisan vendor:publish from command line. Is this the correct way to proceed?

25 Jul
4 months 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.

'''

05 Jul
5 months 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');

seems to work exactly like this and why?

$this->publishes([
            dirname(dirname(__FILE__)).
                '/config/mypackage.php' => config_path('mypackage.php'),
        ]);
01 Jul
5 months 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 an 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 a message error.

15 Jun
5 months 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. Thanks for all the replies

11 Jun
6 months 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 send the 500 error. Should I use both controller and view for this purpose or I have to register an Exception Handler?

05 Apr
8 months 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