xmarks

Hire Me

Experience

23,060

18 Best Reply Awards

  • Member Since 9 Months Ago
  • 111 Lessons Completed
  • 2 Favorites

12th January, 2018

xmarks left a reply on I Am Unable To Install Laravel On My Machine • 1 week ago

I do not know if you have solved this yet.

  • Try to Uninstall Virtualbox and Vagrant.
  • After that, go to your User Folder: C:\Users\your_user
  • Manually Delete: .vagrant.d, .VirtualBox,VirtualBox VMs
  • Run a clean-up with cCleaner: https://www.piriform.com/ccleaner/download
    • Run a Cleanup
    • Clean the Registry as well
  • Reinstall Virtualbox first
  • Reinstall Vagrant
  • Try to download the laravel box again vagrant box add laravel/homestead (Again Command Line in Administrator Model)

Also note this from the Documentation:

If you are using Windows, you may need to enable hardware virtualization (VT-x). It can usually be enabled via your BIOS. If you are using Hyper-V on a UEFI system you may additionally need to disable Hyper-V in order to access VT-x.

11th January, 2018

xmarks left a reply on Redirecting Back To Intended Laravel 5.5 • 1 week ago

Just add the Auth Middleware to your Controller for the specific Method:

/**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        // Only Authenticated Users can access Cities jSON request
        $this->middleware('auth', ['only' => [
            'specificMethod_1', 'specificMethod_2'
        ]]);
    }

Or to all Except a Specific Method:

/**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        // Only Authenticated Users can access Cities jSON request
        $this->middleware('auth', ['except' => [
            'specificMethod'
        ]]);
    }

Laravel takes care of it out-of-the-box.

If the user is required to be authenticated, they will, and then they will get redirected to where they were previously.

xmarks left a reply on I Am Unable To Install Laravel On My Machine • 1 week ago

Are you on Windows 10?

First try to run the Command-Line as Administrator.

If that does not work, I see that Vagrant 2.0.1 is reported Here to have broken something on Windows. So try to uninstall and reinstall Vagrant 2.0.0.

Although I have Vagrant 2.0.1 and everything seems to be working fine for me.

xmarks left a reply on PHP CODE IN LARAVEL • 1 week ago

You should avoid any queries inside your View.

These should be done in the Controller and/or Model Level. From your View you should simply pass a request to the Controller, and it would give you a response back into your View.

10th January, 2018

xmarks left a reply on -> OrWhereHas Failed Fetch Data From Multiple Tables • 1 week ago

You do not need to do that. Instead of:

->orWhereHas('writter', function ($query) use ($keyword) {
            $query->where('nama_penulis', 'like', '%'.$keyword.'%');
        })

You do:

->orWhereHas('writter', function ($query) use ($keyword) {
            $query->whereRaw('LOWER(nama_penulis) like ?', "%$keyword%"); // Only this needs to be changed
        })

xmarks left a reply on Handling Large Dataset (1000+) In VueJS • 1 week ago

Adding to the response from @Spillmester there is a nice package for Laravel to ease the implementation of DataTables: yajra/laravel-datatables

Search and pagination are handled server-side through AJAX.

Bootstrap 3 theme included.

This is not VUEjs, but if all you want is to show a table with pagination and searchable, I think as well that using DataTables would be your best solution.

xmarks left a reply on -> OrWhereHas Failed Fetch Data From Multiple Tables • 1 week ago

You're welcome, I am glad that worked out.

As for ilike, I thought it was not recognized on MySQL from what I have read. My solution with whereRaw was meant to add support so your application works both locally on MySQL and Live on PostgreSQL.

9th January, 2018

xmarks left a reply on -> OrWhereHas Failed Fetch Data From Multiple Tables • 1 week ago

I believe the issue might be that Postgres Does not work well with like, as for Postgres like is case sensitive while for MySQL is by default Case Insensitive. Postgres has ilike for case insensitive but that does not work with mySQL...

Try using whereRaw instead. For Example:

$query = Book::whereRaw('LOWER(judul) like ?', "%$keyword%")
    ->orWhereRaw('LOWER(label) like ?', "%$keyword%")
...

This has worked for me on Heroku with no problems.

Also, I advise:

  • Testing the code 1 by 1, as you add more conditions to see if it fails anywhere else
  • Install and enable debugbar so you can see the query that is being executed on Heroku-side
  • Install HeidiSQL which has a PostgreSQL Connection Option. I have found it useful to get the Query executed from DebugBar, and execute it on HeidiSQL to get more information on where the code was failing.

8th January, 2018

xmarks left a reply on User (client) Accounts & Sub Accounts? • 2 weeks ago

adding to the answer from @andonovn

You can modify the default users table, created by the laravel php artisan make:auth by adding a parent_id field (or users_id if you want to follow default Laravel naming conventions), so you will end up with (at it's simplest):

  • users table fields => | id | parent_id | name | password | created_at | updated_at |

From here, you connect users table, with itself, thus creating a parent-child relation.

When a Client, from their profile-page creates new Sub Accounts, it's ID is added to the parent_id field.

You will also require something to differentiate Default Clients from SubAccount Clients. You can:

  • Add a server-side logic, by adding a field main_account => which would be true or false for example
  • Or a server-side logic, where you check the client if they have any value in their parent_id field.
    • If parent_id = null, this is a Main Account
    • If parent_id !=null, this is a SubAccount

And you can show different Views based on this logic, with different functions (SubAccounts can not create themselves other SubAccounts)

29th December, 2017

xmarks left a reply on Should I Repeat Separate Or Reuse A Nested Controller That Has Overlapping Purpose? • 3 weeks ago

Could you give an example of what you actually intend to do?

If I am understanding you correctly, you intend to have 4 tables?

  • videos / Video Model / VideosController
  • skills / Skill Model / SkillsController
  • strengths / Strength Model / StrengthsController
  • flexibilities / Flexibility Model / FlexibilitiesController

And you would end up with:

  • videos table => | id | skill_id | strength_id | flexibility_id | name |
  • skills table => | id | name | other_data |...
  • strengths table => | id | name | other_data |...
  • flexibilities table => | id | name | other_data |...

Video Model would have belongsTo relation to all other tables, while all other tables would have hasMany relation to Videos:

// Video Model
public function skill() { return $this->belongsTo(Skill::class); }
public function strength() { return $this->belongsTo(Strength::class); }
public function flexibility() { return $this->belongsTo(Flexibility::class); }

// Skill Model
public function videos() { return $this->hasMany(Video::class); }

// Strength Model
public function videos() { return $this->hasMany(Video::class); }

// Flexibility Model
public function videos() { return $this->hasMany(Video::class); }

If that is the case, what kind of data would these tables store exactly? I feel you might be doing too much if there are not really that much data being stored on each separate table.

Having many tables instead of 1 isn't really making things simpler. You should focus on having simple-code, but not necessarily simpler storage for that code. The database won't mind if you have 3-4 more Columns in the videos table.

If a category could have different set of data, as you said, you could store them in the same table, and end up with null-values, but depending on the type of data, and how much data it is, I do not think it should take much more space:

  • categories table => | id | name | data_strength_1 | data_strength_2 | data_skill_1 | data_flexibility_1 | ... When you select the data, you could specify them in the select:
$strengthVideos = Video::where('category_id', '=', '1' /* strength */)->select('id', 'name', 'data_strength_1', 'data_strength_2')->get();

If 1 video can have more than 1-category, on the other hand, you can have a pivot table:

  • videos table => | id | name |
  • categories table => | id | name |
  • category_video table => | category_id | video_id |

So now you can match 1-video with many categories. And 1-category with Many Videos. This is a Many-To-Many Relationship.

xmarks left a reply on Suggestions On A How To Carry Out A Particular Task. • 3 weeks ago

OK so from the top of my head, here is what I am thinking:

  • First of all, all buses should have the same seat-positioning. Or you would have to have different seats from the drop-down when the user selects their seat (which is also doable). For this you can use Select2
  • I feel some form of seat-number confirmation / assignment should be available for print to the user in some way. (An e-mail with the order: bus plate, departure_time, seat_number)
  • An e-mail confirmation of the reservation should be sent to the user. In case of a conflict between 2-users trying to reserve the same seat, they should get a notification to take another reservation, or as I said above, maybe assign an empty one in case there aren't many left free, so they do not get left without a seat entirely because they could not come to the system again to change their reservation

Table structure could be:

  • buses => | id | plate?number |
  • seats => | id | bus_id | => I think this will facilitate things. For example, showing a list of seats from a specific bus. Or if in the future, you might get different bus-sizes, with different seat count
  • events => | id | bus_id |
  • reservations => | id | event_id | client_id => default(null) | seat_id | reserved => default(false) |

So here is my thinking.

  • When you create an event, you select some Buses for it.
  • On Event Creation, the reservations table will populate, with the reserved field defaulting to false and client_id defaulting to null.
  • When client wants to join an event, a list of Bus-Seats will be available, where reserved = false.
  • When user selects a Seat and Submits the form, the Appropriate reservations table will update with the user's ID, and reserved = true.
  • From here you can see which seats are still available. You can get data for the User: Event, Bus, Seat, etc.

I might have missed something but I think the core is here.

xmarks left a reply on Multirelations With 3 Tables • 3 weeks ago

I am not that great with programming myself. As I stated above, this is my "Personal Opinion". You can follow your own goals or wait for someone else to give their opinion which might support yours.

Games and Platforms are fine to have a relation. Did you read my post above?

Again:

Your users table should have:

  • id => primary Key

Your games table should have:

  • id => Primary Key
  • user_id => Foreign Key, related to users table // If you are saving a list of games for a User, otherwise, you can remove this as well.

Your platforms table should have:

  • id => Primary Key

You should have a Pivot Table game_platform for the relation between games and platforms, which should have these fields:

  • game_id => Foreign Key to games Table
  • platform_id => Foreign Key to platforms Table

If you want games under PC Platform then you will end up with something like:

// In your Controller
$platform = Platform::where('name', '=', 'PC')->with('games')->get();

// In your View
<ul>
    @foreach($platform->games as $game)
        <li>{{ $game->name }}</li>
    @endforeach 
</ul>

If you want users, who own a game, under PC Platform:

// Your Controller
$platform = Platform::where('name', '=', 'PC')->with('games.users')->get();

// Your View
<ul>
    <!-- list of games -->
    @foreach($platform->games as $game)
        <li>{{ $game->name }}</li>
        
        <!-- For Each Game, list of users who own it -->
        <ul>
            @foreach($game->users as $user)
                <li>{{ $user->name }}
            @endforeach 
        </ul>
    @endforeach 
</ul>

xmarks left a reply on Multirelations With 3 Tables • 3 weeks ago

Well first of all, I must say it is my personal opinion that this relation makes no sense. There is no reason the users table is connected to the platforms table directly. It should connect only through the games table, as I have described above.

Next, as far as I know, Laravel does not support this. So you are probably going to have to write every method yourself to Keep these data in Synchronization.

Finally, I think this might work out for your case. But again this would simply simulate three 2-way pivot tables: game_user, platform_user and game_platform. These are all ManyToMany Relations.

A Many To Many Relation is declared like this:

return $this->belongsToMany('App\Model', 'foreign_key', 'local_key', 'table_name');

So for your case, the User Model is like this:

public function games() {
    return $this->belongsToMany(Games::class, 'user_id', 'id', 'users_games_platforms');
}

public function platforms() {
    return $this->belongsToMany(Platform::class, 'user_id', 'id', 'users_games_platforms');
}

The Game Model:

public function users() {
    return $this->belongsToMany(User::class, 'game_id', 'id', 'users_games_platforms');
}

public function platforms() {
    return $this->belongsToMany(Platform::class, 'game_id', 'id', 'users_games_platforms');
}

The Platform Model:

public function users() {
    return $this->belongsToMany(User::class, 'platform_id', 'id', 'users_games_platforms');
}

public function games() {
    return $this->belongsToMany(Platform::class, 'platform_id', 'id', 'users_games_platforms');
}

So now, if the above works, you should be able to do the following:

  • $user = User::find($id)->with('platforms'); to get the Platforms of a User
  • $user = User::find($id)->with('games'); to get the Games of a User
  • $game = Game::find($id)->with('users'); to get the Users of a Game
  • $platform = Platform::find($id)->with('users'); to get the Users of a Platform

But again I seriously advise against going though with this method and follow the one I posted previously.

xmarks left a reply on If Exist Take Id If Not Create New Client • 3 weeks ago

You can do this:

  • Use Select2 to build a Search-Form. You can check This Tutorial.
  • While you type, the Database will be searched for a Client, which you can select and Submit, so you can for example, be taken to the Client's Page
  • If nothing is found, Select2 has an option to select what you have typed anyhow

You can then create other Routes and Controller, which will try to find the Client-ID (id would be same as name for the case where Client is not found but you selected it anyway).

In case you are dealing with a new Client, you can redirect to a New Route, where you would create this new Client, and the Client Name could be auto-filled.

xmarks left a reply on Should I Repeat Separate Or Reuse A Nested Controller That Has Overlapping Purpose? • 3 weeks ago

First thing that comes to mind, is this necessary?

Wouldn't it be better to have:

  • VideosController => To take care of everything
  • Have a category field in your videos table, which will save data like "skills / flexibility / strength".

So when you need to access "Strength Videos" you can do: $videos = Video::where('category', '=', 'Strength')->get();

Otherwise, you are right. You should have a VideosController, and all other controllers would extend this base-controller. Keep everything here, like validation method, store method, edit method, and so on. DRY (Don't Repeat Yourself)

xmarks left a reply on Suggestions On A How To Carry Out A Particular Task. • 3 weeks ago

I would have some questions:

  • Is it necessary? Or are you trying to make it fancy? Do you have a logic behind this specification?
  • Is this a Bus Service that goes around Town? with regular stops?
  • Or is it a Bus Reservation like a Taxi, for events with a specific destination, like a camping trip.
  • Do you have any method in mind to deal with users trying to get the same seat at the same time? Like an e-mail after the fact that the seat was requested a little-bit sooner by someone else?
  • Would they go back to register again or would a random empty-seat be assigned to this user who lost their reservation?

xmarks left a reply on Making A Laravel 5.4 Query On A JSON Field Containing A JSON Array • 3 weeks ago

Can you modify how this is stored? So that you can remove the [ ] ?

xmarks left a reply on How Can I Display Data Uniformly Insert (include Symbol,space,enter..) • 3 weeks ago

So you are writing this on a textarea HTML-tag? and you wish it to keep it's format?

In that case, you need to be aware first that Laravel strips some special characters when you echo something in blade using this method:

{{ $yourData }}

To stop Laravel from stripping the special characters, you need to do this:

{!! $yourData !!}

Notice: This is not safe. Some of the special characters that Laravel removes also includes things that could be used to hack your application. To avoid that, you need to strip these bad-characters Before Saving them on your database.

For that you need to Sanitize the Input before saving it. I found these packages that you might consider:

xmarks left a reply on Database Design For Ecommerce Website Example • 3 weeks ago

Well this all depends on your specifications.

If you are working on a project from a client, normally first thing to do would be to take the business specifications from that client and start building your Database Relations from there.

You might also look into Spark, if it's a big project, to get you started on a solid foundation. https://spark.laravel.com/

If you are doing something for yourself, the best advise I would give you would be to start small, just the bare minimum. for example:

  • categories table. Maybe do not build a parent-child relation as a start.
  • products table. Start with a name and a price. connect it to the payment system you want to build first, and then start adding to the table things like discount, tax, vat, manufacturer, magazine, and so on...

You should check some of the e-commerce solutions for Laravel:

You can check this tutorial that builds an e-commerce application from scratch, integrated with PayPal.

Hope these help

28th December, 2017

xmarks left a reply on How To Show Project Name In Limited Characters In Laravel? • 3 weeks ago

In your view, do this:

{{ substr($proj->project_name, 0, 10) }}

More available functions Here

xmarks left a reply on How To Build A Worklog Table By Month? • 3 weeks ago

It's gonna be a bit hard for me, without making tests, to provide a working answer right away, but I'll try my best.

First of all, I think you should make the transformations in your View in this case. Some of the logic in the Controller and Model. And just query the data from the Database.

projects Table

| fields | | ------ | | id | | name | | created_at | | updated_at |

worklogs Table

| fields | | ------ | | id | | project_id | | log | | created_at | | updated_at |

Query

Based on the response here, I think this should work:

$year = $request->year;

$workLogs = Project::leftJoin('worklogs' 'projects.id', '=', 'worklongs.project_id')
    ->whereRaw("(YEAR(worklongs.created_at) =  ?)", [$year]);
    ->select(
        'projects.id as id',
        'projects.name as name',
        
        DB::raw('MONTHNAME(worklogs.created_at) as month'),
        DB::raw('SUM(worklogs.id as month_total)')
    )->orderBy('id', 'month')
    ->groupBy('month')->get();

This query will need to be tweaked a little so it shows something when the month_count is 0. This should get data like below:

| id | name | month | month_total | | ------ | ------ | ------ | ------ | | 1 | project_1 | January | 5 | | 1 | project_1 | February | 10 | | 2 | project_2 | January | 15 | | 3 | project_3 | December | 4 |

Next, Group them by ID to separate Projects
$projects = $workLogs->groupBy('id');

This will give a collection, groupedBy Projects.

View

<table class="table table-striped table-responsive">
    <thead>
        <tr>
            <th>Project</th>
            <th>January</th>
            <th>February</th>
            <th>March</th>
            <th>April</th>
            <th>May</th>
            <th>June</th>
            <th>July</th>
            <th>August</th>
            <th>September</th>
            <th>October</th>
            <th>November</th>
            <th>December</th>
            <th>Total</th>
        </tr>
    </thead>
    
    <tbody>
    <!-- Treat each $projects Collection as 1-Project -->
        @foreach($projects as $project)
            <tr>
                <th scope="row">{{ $project->first()->id }}</th>
                <!-- Treat the data inside each project as 1-separate Worklog -->
                <!-- Assuming the Query is fixed above - Each month should be iterated -->
                @foreach($project->all() as $worklog)
                    <td>{{ $worklog->month_total }}</td>
                @endforeach
                <td>{{ $project->sum('month_total') }}</td> <!-- Not sure how to call this part also, need to check results -->
            </tr>
        @endforeach
    </tbody>
</table>

xmarks left a reply on How To Build A Worklog Table By Month? • 3 weeks ago

How do you differentiate years here?

Are worklogs from January 2016 and worklogs from January 2017 both summed-up in the same Table-cell?

xmarks left a reply on Handling AdmineLTE + Custom JQuery Scripts Using WebPack (Laravel Mix) • 3 weeks ago

I see. I did not know you had renamed app.js into scripts.js.

xmarks left a reply on Handling AdmineLTE + Custom JQuery Scripts Using WebPack (Laravel Mix) • 3 weeks ago

I have tried this a few times as well, and the Minification that is done by mix.js seems to break some of the scripts if added directly like this.

Also, it seems you have completely removed Bootstrap.js, jQuery, and other stuff like CSRF token for Laravel.

You can also add scripts from: resources\assets\js\app.js. You can include the other files there like the Bootstrap file is included. So simply add these there after VUE-section (or after bootstrap if you have removed VUE):

require('./scripts');
require('./AdminLTE-app');
require('./functions');
require('./common');
require('./home');
require('./main');
require('./product');
require('./labels');
require('./login');
require('./purchase');
require('./report');

And change webpack.mix.js back to:

mix.js('resources/assets/js/app.js', 'public/js')
   .sass(['resources/assets/sass/app.scss', 'resources/assets/css/app.scss'], 'public/css')
   .copy('resources/assets/js/lang', 'public/js/lang');

xmarks left a reply on How To Loop Data Into Table When The Data Column Is Less Than Column Header? • 3 weeks ago

Well we only have your view to work with.

If you want help to optimize the logic from the root, then you probably will need to share your Database Structure and Controller for this section.

xmarks left a reply on How To Loop Data Into Table When The Data Column Is Less Than Column Header? • 3 weeks ago

Well 1 solution comes to mind with a simple if-else statement. Since you need the price, or "-", you have to check for each case.

As @Snapey said tho, this would involve logic in the View:

<?php
  use Carbon\Carbon;

  foreach($results as $key => $r) : ?>
    <tr><?php
        $price_n_date = explode(',',  $r->price_date);      
        foreach ($price_n_date as $value) {
        list($price,$date) = explode ('/',$value)

        // First, you need to get the Day, so you can switch it
        $timestemp = "2016-4-5 05:06:01";
        $day = Carbon\Carbon::createFromFormat('Y-m-d', $date)->day; // I believe this will be a string

        // Check Each Condition - If True, print price, else print '-'
        ( $day == '1' ? echo '<td>'.$price.'</td>'; : echo '<td> - </td>'; )
        ( $day == '2' ? echo '<td>'.$price.'</td>'; : echo '<td> - </td>'; )
        ( $day == '3' ? echo '<td>'.$price.'</td>'; : echo '<td> - </td>'; )

        // .....

        ( $day == '30' ? echo '<td>'.$price.'</td>'; : echo '<td> - </td>'; )
        ( $day == '31' ? echo '<td>'.$price.'</td>'; : echo '<td> - </td>'; ) ?>
      
    </tr><?php 
  endforeach;
?>

xmarks left a reply on I Can Not Retrieve Flashed Inputs With The Metod Named WithInput() • 3 weeks ago

withInput() Returns Form-Data that has been input by user, so you can autofill the Forms with the old data, and user can review any errors during their Submit of the Form.

If you intend to return a Flash-message, or data, you need to specify a variable and the data like so:

return redirect()->back()
    ->with('variable_name', 'a custom message for this flash variable');

You should now be able to access $variable_name once redirected, for example to flash an error-message.

xmarks left a reply on Dropbox Integration With Voyager • 3 weeks ago

I have. No response there unfortunately. Although I do not think it's Voyager's issue. I might be wrong.

If I knew how to fix it it and submit a PR I wouldn't be asking around about it :(

27th December, 2017

xmarks left a reply on Problems With Hosting - PHP7 • 3 weeks ago

as both I and @cmdobueno suggested, Linode and Digital Ocean are good Hosting Providers.

Only problem is, they do not come with a Control Panel. I can suggesting Installing something like:

xmarks left a reply on How Do I Access Or Reference My Php Installation On Homestead From Inside The Host. • 3 weeks ago

as I mentioned, this does not Install PHP on your Main Machine. It just comes bundled with WAMP. So it will not mess with anything else. It will not be running as a background process.

On the other hand, you can access your Virtual Machine like this:

  • Go to your Homestead Directory, by default ~\Homestead
  • From there, up the machine with vagrant up
  • After machine is up, you can vagrant ssh into the machine
  • From the virtual machine, navigate to your project, and you can execute any PHP-commands from there.

xmarks left a reply on Multirelations With 3 Tables • 3 weeks ago

As far as I understand, you should have these relations:

  • User Model:
public function games() {
    return $this->hasMany(Game::class);
}
  • Game Model:
public function user() {
    return $this->belongsTo(User::class);
}

public function platforms() {
    return $this->belongsToMany(Platform::class);
}
  • Platform Model:
public function games() {
    return $this->belongsToMany(Game::class);
}

Your users table should have:

  • id => primary Key

Your games table should have:

  • id => Primary Key
  • user_id => Foreign Key, related to users table

Your platforms table should have:

  • id => Primary Key

You should have a Pivot Table game_platform for the relation between games and platforms, which should have these fields:

  • game_id => Foreign Key to games Table
  • platform_id => Foreign Key to platforms Table

With these relations and table-structure, everything should work as I have mentioned on my previous reply. If you are using different Table Names and Primary / Foreign Key names, then the relations here should be changed to match those table names and Primary / Foreign Key names.

xmarks left a reply on Multirelations With 3 Tables • 3 weeks ago

does this currently not work?

// Get all data - This would be in the controller
$user = User::find($id)->with('games.platforms');

// Get User Games
$user->games;

// Get Platform for each game - This could be converted into blade for the view to Render games and their Platforms
foreach($user->games as $game) {
    foreach($game->platforms as $platform) {
        echo $platform->name;
    }
}

xmarks left a reply on How Do I Access Or Reference My Php Installation On Homestead From Inside The Host. • 3 weeks ago

If you are on Windows, what I have done is Install WAMP which comes Bundled with PHP.

You do not need to run it, ever.

Then create a Windows Path File, and set the PHP Executable from within WAMP. Check this tutorial on setting a new PATH: https://john-dugan.com/add-php-windows-path-variable/

xmarks left a reply on How To Test All Forms In My Project • 3 weeks ago

Yeah you would have to manually create all these tests 1 by 1. Run them once after each new test, and make sure everything is returning the correct error / success message.

I do not think there are any shortcuts to this. You just have to decide if testing everything that is normally covered by the validation is necessary, or if you should only test a few of the steps, or if you should even simply test if the form Submits or not.

But I think that for such a case, you could simply build the validation. Test everything yourself by submitting it in all the different ways (which is a lot faster) and just trust yourself, because I see no reason why this would break in the future.

Only if in the future you add more fields, and you forget to create the validation for them, which I think would be covered by 1-test only. Does the form Submit Successfully? => true / false

26th December, 2017

xmarks left a reply on Does Compiling Asset Make Page Load Faster? • 3 weeks ago

20s for 300Kb... something must be wrong.

Also, consider a CDN, like CloudFlare

xmarks left a reply on Does Compiling Asset Make Page Load Faster? • 3 weeks ago

Test your page before and after compiling everything in 1-file, on the following:

xmarks left a reply on How To Get Data From A Table Which Does Not Have Relationship With The Other One. • 3 weeks ago

But why do it like this?

I think the best way to do this, would be only having 2 tables:

  • users table with data:
      $table->increments('id');
      $table->string('username');
      $table->string('email')->unique();
      $table->string('role')->default('okuyucu');
      $table->string('userImg')->default('profile.jpg');
      $table->string('nameSurname')->default('Not Added');
      $table->string('bio')->default('Reader');
      $table->integer('reputation')->default('0');
      $table->integer('followers')->default('0');
      $table->timestamps();
  • and comments table with data:
      $table->increments('id');
      $table->string('user_id');
      $table->string('comment');
      $table->integer('article_id');
      $table->timestamps();
  • From User Model, the relation:
public function comments()
{
    return $this->hasMany(App\Comment::class);
}
  • From Comment Model, the relation:
public function user()
{
    return $this->belongsTo(App\User::class);
}
  • You can get User Comments by $user->find($id)->comments;
  • You can get the owner of the comment by $comment->user;

xmarks left a reply on Dropbox Integration With Voyager • 3 weeks ago

I have been trying to use that package, but still it's giving me the error as shown.

So what I have done:

Added Voyager Service Provider: https://voyager.readme.io/docs/adding-the-service-provider On file: config\app.php

'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
        // ...

        /*
         * Package Service Providers...
         */
        Laravel\Tinker\TinkerServiceProvider::class,
        // Voyager Package Service Provider
        TCG\Voyager\VoyagerServiceProvider::class,
                
         /*
         * Application Service Providers...
         */
        // ...

],

Installed Voyager Dummy: php artisan voyager:install --with-dummy

Installed this Dropbox Package: https://github.com/benjamincrozat/laravel-dropbox-driver, which includes the Package from Spatie: https://github.com/spatie/flysystem-dropbox as well as the Dropbox Service Provider described on your link: https://murze.be/dropbox-will-turn-off-v1-of-their-api-soon-its-time-to-update-your-php-application

Added Service Provider for this Package On file: config\app.php:

'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
        // ...

        /*
         * Package Service Providers...
         */
        Laravel\Tinker\TinkerServiceProvider::class,
        // Voyager Package Service Provider
        TCG\Voyager\VoyagerServiceProvider::class,
        // Dropbox Package Service Provider
        BC\Laravel\DropboxDriver\ServiceProvider::class,
                
                /*
         * Application Service Providers...
         */
        // ...

],

Added Filesystem for the Dropbox Package On file config\filesystems.php:

'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
        ],

        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],

        's3' => [
            'driver' => 's3',
            'key' => env('AWS_KEY'),
            'secret' => env('AWS_SECRET'),
            'region' => env('AWS_REGION'),
            'bucket' => env('AWS_BUCKET'),
        ],

        'dropbox' => [
            'driver' => 'dropbox',
            'token' => env('DROPBOX_TOKEN'),
        ],

],

Created a New Dropbox App. Generated a Key, and added to .env file:

        DROPBOX_TOKEN=<token_string_here>

Changed Voyager Storage Config on file config\voyager.php:

    /*
    |--------------------------------------------------------------------------
    | Storage Config
    |--------------------------------------------------------------------------
    |
    | Here you can specify attributes related to your application file system
    |
    */

    'storage' => [
        // 'disk' => 'public',
        'disk' => 'dropbox',
    ],

Now here is what I get:

FlysystemAdapter.php line 336 has this code:

    /**
     * Get the URL for the file at the given path.
     *
     * @param  string  $path
     * @return string
     */
    public function url($path)
    {
        $adapter = $this->driver->getAdapter();

        if (method_exists($adapter, 'getUrl')) {
            return $adapter->getUrl($path);
        } elseif ($adapter instanceof AwsS3Adapter) {
            return $this->getAwsUrl($adapter, $path);
        } elseif ($adapter instanceof LocalAdapter) {
            return $this->getLocalUrl($path);
        } else {
            throw new RuntimeException('This driver does not support retrieving URLs.');
        }
    }

So I am guessing I will need some form of DropboxAdapter?

Not sure where to go from here...

xmarks left a reply on Change Input Value From Autocomplete • 3 weeks ago

Question: If I am understanding this correctly, what you are doing is, you are checking the received largeur, hauteur and diametre from the Form, and are validating them all in a foreach-loop with your database?

Why are you not using a validation for this? Check this out: https://laravel.com/docs/5.5/validation#rule-exists

Or are you trying to do something else?

xmarks left a reply on How To Test All Forms In My Project • 3 weeks ago

Well you could write a test, where you enter the name and then Submit the form.

You Expect the result to be an error, so you return this error as success.

So for your case, you need these tests:

  • Test name only => Confirm Error Exception "you need to provide an email address" => Success
  • Test name + mail => Confirm Error Exception "You need to provide a password" => Success
  • Test name + mail + password => Confirm Error Exception "You need to confirm your password" => Success
  • Test name + mail + password + password confirm => Confirm Successful Registration => Success

And so on...

xmarks left a reply on Error Page • 3 weeks ago

Well first of all, add validation. Make sure all possible errors are covered from the validation, which will then redirect the user back with the appropriate error message, and this is automatic: https://laravel.com/docs/5.5/validation

Next, you can specify custom break-points, with if-else statement. and If there is an error, do something like:

return redirect()
        ->route('your.route', compact('anyVariables'))
    ->withInput() // This returns old-input of forms, so you can autofill the old data
        ->with('session-message', 'error message');

Or

return redirect()->back()
    ->withInputs() // This returns old-input of forms, so you can autofill the old data
        ->with('session-message', 'error message');

xmarks left a reply on Server Side Data Table EditColumn Eloquent • 3 weeks ago

Then try this:

$doctors = Doctor::with('patients' => function($query) {
    $query->where('created_at', '>=', Carbon::now()->startOfMonth())
        ->where('created_at', '<=', Carbon::now()->endOfMonth());
})->get();

Where you need to get the count, this should work:

$doctor->patients->count();

Note: You need to include the Carbon Facade to use it. Or you can provide the dates in another manner.

xmarks left a reply on User Tracking • 3 weeks ago

@zaster Consider this Package, which does exactly what you ask for and more: https://github.com/owen-it/laravel-auditing

You can work on this package and add a changelog on your dashboard with the information stored. I believe this allows for rolloback functionality as well.

xmarks left a reply on Dropbox Integration With Voyager • 3 weeks ago

bump *

xmarks left a reply on How To Upload Multi Files Images In Laravel • 3 weeks ago

@smallt Maybe you should consider this package: https://github.com/spatie/laravel-medialibrary

xmarks left a reply on PDF Reader Like Flipbook • 3 weeks ago

I found this package: rudrarajiv/flipbook-laravel.

It could be outdated as it has not received any updates for over 1 year.

Otherwise, here are some jQuery plugins. Most of the good ones are commercial though: https://jqueryhouse.com/20-best-jquery-flipbook-plugins/

And a Listing on Envato: https://codecanyon.net/tags/flipbook?sort=sales

xmarks left a reply on Server Side Data Table EditColumn Eloquent • 3 weeks ago

What is your Table Structure? doctors and patients?

or doctors, patients and visits?

If a Patient visits the doctor more than once, do you count it? Or you just want to count the number of Patients the Doctor has, irrelevant of the number of visits the Patient made?

Also, have you considered this Package to create DataTables? yajra/laravel-datatables

xmarks left a reply on Seeking For Suggestion On Purchase Price History Report Layout In Grid View. • 3 weeks ago

Just in case you do not have a visual representation of your current logic yet, I found this which seems to match your description perfectly: http://webnus.biz/plugins/modern-events-calendar/full-calendar/

Only here it is about events, while you have products.

I think this is a nice design.

22nd December, 2017

xmarks left a reply on Getting Relation Of Relation In Blade • 4 weeks ago

How about:

$user = User::with(array('posts' => function($query) {
        $query->where('approved', 1)->limit(10);
    }, 'posts.categories'))
    ->where([ ['slug', $slug], ['isauthor', 1], ['approved', 1] ])
    ->firstOrFail();

I think this should include everything.

Now, you can use:

  • $user to get user data
  • $user->posts to get user posts

For each post you can do:

@foreach($user->posts as $post)
    {{ $post->title }}
    <br>
    {{ $post->body }}
    <br>
    @foreach($post->categories as $category)
        {{ $category->name . ', ' }}
    @endforeach
@endforeach
Edit Your Profile
Update

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