gidaban79

Experience

3,450

0 Best Reply Awards

  • Member Since 10 Months Ago
  • 28 Lessons Completed
  • 0 Favorites

16th October, 2017

gidaban79 left a reply on Bootstrap Switch And DataTable • 2 days ago

If somebody looking for solution

$('#posts').DataTable({
                "order": [[1, "asc"]],
                "aoColumns": [
                    null,
                    null,
                    null,
                    {"bSortable": false, "bSearchable": false},
                    null, {"bSortable": false, "bSearchable": false},
                    null,
                    null,
                    {"bSortable": false, "bSearchable": false}
                ],
                "fnDrawCallback": function() {
                    $('.grid-switch-released').bootstrapSwitch({
                        size: 'small',
                        onText: 'YES',
                        offText: 'NO',
                        onColor: 'primary',
                        offColor: 'default',
                        onSwitchChange: function (event, state) {

                            $(this).val(state ? 'on' : 'off');

                            var pk = $(this).data('key');
                            var value = $(this).val();
                            var publishDate = $('[data-published-id="' + pk + '"]');
                            var featureDate = $('[data-featured-id="' + pk + '"]');

                            var action = $(this).data('action');
                            $.ajax({
                                url: "/admins/posts/" + pk,
                                type: "POST",
                                data: {
                                    released: value,
                                    action: action,
                                    _token: '{{csrf_token()}}',
                                    _method: 'PUT'
                                },
                                success: function (data) {
                                    if (data.action == "publish") {
                                        publishDate.html(data.date);
                                    } else {
                                        featureDate.html(data.date);
                                    }
                                    toastr.success(data.message);
                                }
                            });
                        }
                    });
                }
            });

10th October, 2017

gidaban79 started a new conversation Bootstrap Switch And DataTable • 1 week ago

Hello all,

In my Admin Panel i use 2 plugins for display data from Database:

1 - Bootstrap Switch 2 - DataTable

So far i don't have problems with Datatable and display it, but i want to add one column with swith button for change status of featured post, script working only on first page. For others page is just checkbox.

My code is below.

''' $('#posts').DataTable({ 'paging': true, 'lengthChange': false, 'searching': true, 'ordering': true, 'info': true, 'autoWidth': true }); $('.grid-switch-released').bootstrapSwitch({ size:'mini', onText: 'YES', offText: 'NO', onColor: 'primary', offColor: 'default', onSwitchChange: function(event, state){

                $(this).val(state ? 'on' : 'off');

                var pk = $(this).data('key');
                var value = $(this).val();

                $.ajax({
                    url: "/admin/posts/" + pk,
                    type: "POST",
                    data: {
                        released: value,
                        _token: '{{csrf_token()}}',
                        _method: 'PUT'
                    },
                    success: function (data) {
                        toastr.success(data.message);
                    }
                });
            }
        });

'''

gidaban79 left a reply on How To Do PHPUni Tests In CLI Script? • 1 week ago

Thanks :)

5th October, 2017

gidaban79 started a new conversation How To Do PHPUni Tests In CLI Script? • 1 week ago

I know subject is not with Laravel, but maybe someone can expain me how to do PHPUnit test?

I have already script in PHP i know it works, but how to write test for it ?

it's simple script to generate multiplication table. Thing is script generates and display data.

1st October, 2017

gidaban79 left a reply on Default Redirect After Login In Laravel 5.5 • 2 weeks ago

@AlbertMulaki

Thanks Works well

gidaban79 left a reply on Default Redirect After Login In Laravel 5.5 • 2 weeks ago

'''| | GET|HEAD | / | app.index | App\Http\Controllers\[email protected] | web |'''

gidaban79 left a reply on Default Redirect After Login In Laravel 5.5 • 2 weeks ago

'''Route::get('/', ['uses'=>'[email protected]','as'=>'app.index']);'''

This redirection is correct, but if you will enter again on login form i got redirection to "/home"

gidaban79 left a reply on Default Redirect After Login In Laravel 5.5 • 2 weeks ago

Yes i did it

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
use Auth;
class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */

    use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = '/';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }
    protected function redirectTo()
    {
        return redirect('/');
    }
    public function login(Request $request){
        $this->validate($request,[
            'email'=>'required|email',
            'password'=>'required'
        ]);
        if(auth()->attempt(['email'=>$request->email,'password'=>$request->password])){

            if(auth()->user()->confirmed==0){
                Auth::logout();
                return back()->with('warning', 'Your account has not yet been activated. Please check Your email');
            }
            return redirect(route('app.index'));
        }else {
            return back()->with('warning', 'Address email or/and password are incorrect.');
        }
    }
}

gidaban79 started a new conversation Default Redirect After Login In Laravel 5.5 • 2 weeks ago

Hi,

On beginning i will answer yes i have changed "$redirectTo" for other route after login, register. But when i click again on login link i'm redirecting on "/home". thing is i have to make a route in web.php file because without it i got exception.

Any ideas how i can change it?

16th June, 2017

gidaban79 left a reply on Carbon And Conversion Date • 4 months ago

Sorry for late reply i was busy

input form

<input type="text" name="featured_to" />

just example.

And now user picking date by "Bootstrap Datepicker", after it field is filled "16/06/2017" -"dd/mm/yyyy"

After send form i catch it "$request->published_at"n still is only date, next i want to use "Carbon" for convert it Carbon::createFromFormat('d/m/Y H:i:s',$request->published_at)->toDateTimeString() after it i getting date in correct format, time not date, time is equal to time send of form, but i need date with time in midnight. 2017-06-16 00:00:00

29th May, 2017

gidaban79 started a new conversation Carbon And Conversion Date • 4 months ago

Hello all,

I hope You are well :)

in my controller i have code for store informations from input, is date in format d/m/Y example 29/05/2017

and now i use code:

$post->featured_to = $request->featured ? Carbon::createFromFormat('d/m/Y', $request->featured_to)->toDateTimeString() : NULL;

Date is convert, but i have to convert date until midnight like '2017-05-31 00:00:00' but date is converted until hour what time i do convert,

Any ideas how to fix it?

1st April, 2017

gidaban79 left a reply on Store Comments In DB • 6 months ago

Any ideas ?

or make manually table for each module ?

30th March, 2017

gidaban79 left a reply on Store Comments In DB • 6 months ago

What i have:

CommentModule.php

 public function comments(){
        return $this->hasMany(Comment::class,'module_id');
    }

Comment.php

public function module(){
        return $this->belongsTo(CommentModule::class);
    }

Map.php

 public function comments(){
        return $this->hasMany(Comment::class,'parent_id');
    }

Controller

$module = new CommentModule();
$module->comments()->where('parent_id',1)->get();

29th March, 2017

gidaban79 left a reply on Store Comments In DB • 6 months ago

but what if i will add more "modules" and i want to add comments ? Every time i have add new column ?

i thing best way is like now is.

gidaban79 left a reply on Store Comments In DB • 6 months ago

module_id -> is id of parent module, i want store all comments in one table. Then i have to store in table for with one module is comment, for example:

id:10;
user_id:15 -> who add comment;
module_id:1 -> is blog. module_id:2 is gallery
parent_id:45 -> is number id of post number

gidaban79 left a reply on Store Comments In DB • 6 months ago

    public function comments(){
        return $this->hasMany(Comment::class,'parent_id');
    }

Example of function for getting data, Right ? but how pass module id?

in DB i have stored:

id,
user_id, => id of user
module_id, => and now how to pass it ?
parent_id, => id of parent id post or gallery
body,
and timestamps 

gidaban79 started a new conversation Store Comments In DB • 6 months ago

Hello Everyone :)

Request:

Store all comments in one table.

Solution:

Design table:

   ``` $table->increments('id');
        $table->integer('user_id')->unsigned();
        $table->integer('module_id')->unsigned();
        $table->integer('parent_id')->insignrd();
        $table->text('body');
        $table->timestamps();```

easy, but now to use eloquents to getting data from table? if "blog" is module "1", "gallery" is module "2"?

Numbers of modules can change ?

Any ideas ?

Many Thanks.

27th February, 2017

gidaban79 left a reply on How To Design Database For Website With Events • 7 months ago

@Snapey

Thanks,

Is not a football events, it will be for concerts, picnics.

Just i have problem how to store it most of usable in database?

Single event with single date is easy, but what if this events is in every Friday of Summer ? Loop all possible dates and save in different table? or save in same table with single event ?

How will be better in future for searching, displaying, listing?

26th February, 2017

gidaban79 left a reply on How To Design Database For Website With Events • 7 months ago

@jlrdw yes events site with cycle events.

juts thing is how will be best way for store dates in database. If one Event can be in every Friday of March ?

if you dont have a strictly dates,

event date 1/03/2017 - 01/04/2017 - but only in Fridays ?

gidaban79 left a reply on How To Design Database For Website With Events • 7 months ago

@lars6 i mean tables in database.

gidaban79 started a new conversation How To Design Database For Website With Events • 7 months ago

Hello guy,

Anybody have experience with design database for it ?

to be honest i dont know how to proper design it for dates.

what i need is events in range of dates, between two dates, for example this event is in march but only in Tuesday and Thursday every week?

Thanks for all suggestion :)

5th January, 2017

gidaban79 started a new conversation Prefer Directory For Storage Images Of Galleries • 9 months ago

Hello and Happy new Year:)

Could please somebody help me with choice of best storage path for images? What is best way or best practice? Use a public path "publuc/images" or storage path of application?

Thanks for all help

Regards Tomek

Edit Your Profile
Update

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