mac03733

Experience

1,720

0 Best Reply Awards

  • Member Since 3 Months Ago
  • 0 Lessons Completed
  • 0 Favorites

15th October, 2018

mac03733 left a reply on Get Records From Db BUT Without Repeating A Specific Column • 14 hours ago

hahaha ..sure y not

4th October, 2018

mac03733 left a reply on Get Records From Db BUT Without Repeating A Specific Column • 1 week ago

solutions i ended up with

$users = DB::table('users')
        ->select('id','name', 'email')
        ->get();

foreach($users->unique('name') as $user){
  //....
}

or

$users = User::groupBy('name')->get();
       

mac03733 left a reply on Get Records From Db BUT Without Repeating A Specific Column • 1 week ago

@petritr the structure of the DB is perfect ..i expect it to repeat the value. what i need help with is wat i stated in the question

please let me know in case the question is not clear , THANK 4 attempt though

mac03733 left a reply on [Vue Warn]: Unknown Custom Element: <example-component> - Did You Register The Component Correctly? • 1 week ago

and go to where u import your app.js ...if there is a defer attribute on the script tag .remove the "defer" ..

recompile and test

mac03733 left a reply on [Vue Warn]: Unknown Custom Element: <example-component> - Did You Register The Component Correctly? • 1 week ago

can u also check your browser console and see if there is any message

mac03733 started a new conversation Get Records From Db BUT Without Repeating A Specific Column • 1 week ago

is there some fancy laravel / eloquent way of doing what th question states.

assuming i have a column named 'bluh' , if "bluh" has a reapeating value accross other rows ..only get one

27th September, 2018

mac03733 left a reply on {{ __('web.name') }} Syntax ? • 2 weeks ago

does the "web." point to some file or smothing

mac03733 started a new conversation {{ __('web.name') }} Syntax ? • 2 weeks ago

can someone tell me what that syntax implies /or does

12th September, 2018

mac03733 left a reply on How To Use Registration Form For Two Tables • 1 month ago

@Sergiu17 .. i was just passing by ...like the way u answer ... please keep it up

3rd September, 2018

mac03733 left a reply on Inserting Values Into Foreign Key Table And Primary Key Table • 1 month ago

have u considered doing it this way

  1. this line , u can remove it
$table->foreign('thief_id')->references('id')->on('thieves');

then in Thieves model hav somthing like

public function cars(){
    return $this->hasMany('App\Car');
}

then in cars model add somthing like

public function cars(){
    return $this->belongsTo('App\Thief');
}

then when u save a car u can give it the primary key of the thief as a foriegn key

you can look add laravel relasionship documentation for bettter understanding

Hope that helps

30th August, 2018

mac03733 left a reply on Vhost ?? Php Artisan Serve ???? • 1 month ago

so are there specific projects that require

php artisan serve

because i only started using it when i cloned a project and all it showed was a blank page when i try

127.0.0.1/appfolder/public

but worked whn i used

php artisan serve

mac03733 started a new conversation Vhost ?? Php Artisan Serve ???? • 1 month ago

wat is need for using ... vhost or php artisan serve . so far i have just been using 127.0.0.1/appfolder/public

am on laravel5.6 and using xamp

29th August, 2018

mac03733 started a new conversation Laravel5.6 + Vue + Vuex + Vue-router • 1 month ago

hi ..i just started learning laravel about 2 months back .. and now i need to combine with vue + vuex + vue-router ..can someone recommend material or a good tutorial implementing all those in laravel ..

thank you.. nd love the support newbies get from this community .. really makes the learning easier

mac03733 left a reply on Create A New Table Or Store In Same • 1 month ago

i would go for one table. My reasoning being you dont hav to query multiple tables if u need data about several states and its much easier to manage

hope i understood ur question nd the answer is helpful

24th August, 2018

mac03733 left a reply on Laravel 5.6 + Materialize | Mdbootstrap Without Removing Bootstrap 4 • 1 month ago

i know the question might sound silly to those of you used to this .. but can i please get some help ..THANK U

mac03733 started a new conversation Laravel 5.6 + Materialize | Mdbootstrap Without Removing Bootstrap 4 • 1 month ago

hi guys, newbie here ... am trying to start using material design for my projects .. for some reason its not as easy as i thought it would be. can someone please advice on how to setup materialize without having to remove bootstrap preferably using npm

as a side question ..which would u recommend materialize vs mdbootstrap

23rd August, 2018

mac03733 left a reply on What To Do After NPM ? • 1 month ago

@tykus thanks... i only used the first import.and it works ............ to avoid asking again the next time i do an npm install

is it basically the same set of steps for everything ...

for example assuming i do something like

npm install datatable

mac03733 started a new conversation What To Do After NPM ? • 1 month ago

already feeling silly as i ask this question ..

i just ran "on laravel 5.6"

npm install mdbootstrap

now what do i need to do to be able to start using it use it..

22nd August, 2018

mac03733 left a reply on No Debug Page ( Debug Is True ) • 1 month ago

Sweet .. php artisan config:clear solved it . thanks for the help guys

mac03733 left a reply on How To Solve Trying To Get Property 'name' Of Non-object • 1 month ago

@AKKI1111 where is the code?

21st August, 2018

mac03733 left a reply on No Debug Page ( Debug Is True ) • 1 month ago

@Talinon ...will give that a try... lol ... didnt spot that...thanks for pointing it out

mac03733 left a reply on No Debug Page ( Debug Is True ) • 1 month ago

.env

APP_DEBUG=true

app.php

'debug' => env('APP_DEBUG', false),

mac03733 left a reply on No Debug Page ( Debug Is True ) • 1 month ago

@Snapey config('app.debug') returns false .but when i check it both files its set to true.

i already ran cache:clear command ..still getting the same results

mac03733 left a reply on No Debug Page ( Debug Is True ) • 1 month ago

@Nash i already cleared th cache ...and iv tried changing it in both th app.php and the .env

20th August, 2018

mac03733 left a reply on No Debug Page ( Debug Is True ) • 1 month ago

@Talinon i already have 775 permission recursively applied to storage

mac03733 started a new conversation No Debug Page ( Debug Is True ) • 1 month ago

hi .. i keep getting "Whoops, looks like something went wrong." even tho debug is set to true. the app is working on my local machine. but on the server its giving the Whoops error. how can i debug this

mac03733 left a reply on DataTables Warning • 1 month ago

in controller

  public function getAllUsers(Request $request)  {

                $columns = array(
                                    0 =>'id',
                                    1 =>'userImg',
                                    2=> 'name',
                                    3=> 'email',
                                    4=> 'profile'

                                );

                $totalData = User::count();

                $totalFiltered = $totalData;

                $limit = $request->input('length');
                $start = $request->input('start');
                $order = $columns[$request->input('order.0.column')];
                $dir = $request->input('order.0.dir');

                if(empty($request->input('search.value')))
                {
                    $Users = User::offset($start)
                                 ->limit($limit)
                                 ->orderBy($order,$dir)
                                 ->get();
                }
                else {
                    $search = $request->input('search.value');

                    $Users =  User::where('id','LIKE',"%{$search}%")
                                    ->orWhere('name', 'LIKE',"%{$search}%")
                                    ->orWhere('email', 'LIKE',"%{$search}%")
                                    ->offset($start)
                                    ->limit($limit)
                                    ->orderBy($order,$dir)
                                    ->get();

                    $totalFiltered = User::where('id','LIKE',"%{$search}%")
                                     ->orWhere('name', 'LIKE',"%{$search}%")
                                     ->orWhere('email', 'LIKE',"%{$search}%")
                                     ->count();
                }

                $data = array();
                if(!empty($Users))
                {
                    foreach ($Users as $User)
                    {
                        $show =  route('admin.viewUser',$User->id);
                        $userImg =  asset('storage/images/avatar5.png');

                        $nestedData['id'] = $User->id;
                        $nestedData['userImg'] = "<img class='img-fluid img-responsive img-circle' style='max-width:50px' src='{$userImg}'/>";
                        $nestedData['name'] = $User->name;
                        $nestedData['email'] = $User->email;
                        $nestedData['profile'] = "<a href='{$show}' class='btn d-inline'><i class='fas fa-eye text-dark'></i></a>";

                        $data[] = $nestedData;

                    }
                }

                $json_data = array(
                            "draw"            => intval($request->input('draw')),
                            "recordsTotal"    => intval($totalData),
                            "recordsFiltered" => intval($totalFiltered),
                            "data"            => $data
                            );

                echo json_encode($json_data);


      }

javascript

  $(document).ready(function () {
      $('#user_table_id').DataTable({
          "processing": true,
          "serverSide": true,
          "ajax":{
                   "url": "{{ route('admin.getUsers') }}",
                   "dataType": "json",
                   "type": "POST",
                   "data":{ _token: "{{csrf_token()}}"}
                 },
          "columns": [
              { "data": "id" },
              { "data": "userImg" },
              { "data": "name" },
              { "data": "email" },
              { "data": "profile" }


          ],
          "columnDefs": [
            { "targets": [1,4], "orderable": false }
          
          ]

      });
  });

mac03733 started a new conversation DataTables Warning • 1 month ago

i seem to be getting this alert at random times .the datatable works perfectly thn out of nowhere it gives that alert then goes back to being normal

DataTables warning: table id=user_table_id - Ajax error. For more information about this error, please see http://datatables.net/tn/7

if anyone has ran into this before or knows the possible cause and fix please help.

17th August, 2018

mac03733 left a reply on Exclude A Column Form Datatable Sorting • 1 month ago

@Cronix works like a charm .. thanks a lot

mac03733 started a new conversation Exclude A Column Form Datatable Sorting • 1 month ago

hi ..i am using datatables from datatable.net .. is there a way to exclude a column from being sortable. for example a image column. the library seems to give am error if u try to click sort on such columns

mac03733 left a reply on Uncaught TypeError: Cannot Set Property '$' Of Undefined • 1 month ago

i replaced

var $  = require( 'jquery' );
var dt = require( 'datatables.net' )();

with -> that fixed it

import $ from 'jquery';
import dt from 'datatables.net';

mac03733 started a new conversation Uncaught TypeError: Cannot Set Property '$' Of Undefined • 1 month ago

i am trying to use Datatable from datatable.net these are the steps i followed. i notice this error in my console " Uncaught TypeError: Cannot set property '$' of undefined "

npm install datatables.net    
npm install datatables.net-dt 

then in my app.js

var $  = require( 'jquery' );
var dt = require( 'datatables.net' )();

then in my blade

$(document).ready( function () {

  $('#table_id').DataTable();
} );

for the styling i downloaded th files manually and placed them in my public folder -->if thers a better way please let me knw

  <link href="{{ asset('css/dataTables.bootstrap4.css') }}" rel="stylesheet">
<script src="{{ asset('js/dataTables.bootstrap4.min.js') }}" ></script>

mac03733 left a reply on Best Datatable Plugin For Laravel ? • 1 month ago

this is how i installed it

npm install datatables.net    
npm install datatables.net-dt 

then in my app.js

var $  = require( 'jquery' );
var dt = require( 'datatables.net' )();

then in my blade

$(document).ready( function () {

  $('#table_id').DataTable();
} );

this gave me a barley formatted table and the only way i can think of to customize it is by targeting the elements directly .is there an easyier way

mac03733 left a reply on Best Datatable Plugin For Laravel ? • 1 month ago

@phpMick i tried that one on a sample project ... but cant seem to get the customization right

mac03733 started a new conversation Best Datatable Plugin For Laravel ? • 1 month ago

can anyone recommend a good datatable plugin for laravel, preferably with Server-side processing and easy to implement

16th August, 2018

mac03733 left a reply on About Application Deployment • 1 month ago

there are platforms that help do it for you eg - Forge. but if u prefer to do it yourself on a VPS you can visit this link https://www.youtube.com/watch?v=5Y4STYfvpk4&list=PLwAKR305CRO_WMJAJxGz6UCViQyAjdjgo .its a detailed playlist on how to setup a LEMP stack and deploy your app

14th August, 2018

mac03733 left a reply on Validating Current Team If User Were To Change Teams In A Different Tab • 2 months ago

why not check if the user belongs to the team they are trying to post under " in the the create post method". or am i not getting the question

13th August, 2018

mac03733 left a reply on Use Named Route And Asset In Controller • 2 months ago

@Cruorzy i already used php artisan storage:link .. i was using the code in my blade template and it works ..but now i needed to move it to my controller

mac03733 left a reply on Admin ,Users ---> Separate Table VS Single Table • 2 months ago

are there any major drawback i should worry bout with any of them .. and which questions or likely situations would require one or the other approach

mac03733 started a new conversation Use Named Route And Asset In Controller • 2 months ago

i am trying to get the image and also set a named route in my controller

  foreach($users as $user){
                  $output .= '
                    <tr>
                      <td >'.$user->id.'</td>
                      <td>
                      <img src="{{ asset("storage/images/avatar5.png") }}" > //here ?? <-------------
                      </td>
                      <td>'.$user->name.'</td>                      
                      <td>
                      <a href="{{route("admin.viewUser",["id"=>'. $user->id .'])}}" class="btn  d-inline"> 
                  
                      </a> //here ?? <-------------
                      </td>
                    </tr>
                  ';
                }

10th August, 2018

mac03733 started a new conversation Admin ,Users ---> Separate Table VS Single Table • 2 months ago

hi guys. i am new to laravel and i know this is probably a matter of preference.

but i am curious which approach is the best

mac03733 left a reply on Relationship With Unknown Foreign Key ( Foreign Key Can Be One Of Two) • 2 months ago

will continue trying to find solve it..thanks for feedback

mac03733 left a reply on Relationship With Unknown Foreign Key ( Foreign Key Can Be One Of Two) • 2 months ago

@cmdobueno and @martinbean somthing to concider on my next project ...THANKS.

being new to laravel and all ..one tutorial says this is best next one says that is best :(

would appreciate some help with my current problem

mac03733 left a reply on Relationship With Unknown Foreign Key ( Foreign Key Can Be One Of Two) • 2 months ago

@martinbean using authorization is not bad.. but if the actors are gonna have different attributes i belive its better to separate them

mac03733 started a new conversation Relationship With Unknown Foreign Key ( Foreign Key Can Be One Of Two) • 2 months ago

hi guys ...i have 3 tables ... 1)users 2)admins 3)messages

use case

->user can message user ->admins and users can message ->admins can message admin

now my question is can anyone advice on how i would set my relationships "considering the foreign key for--> sender and recipient column can change depending on whether its an admin or user model "

so i think i cant do somthing like this

  public function sender(){
      return $this->belongsTo('App\User');
    }

because send could also be

  public function sender(){
      return $this->belongsTo('App\Admin');
    }

same goes for recipient

7th August, 2018

mac03733 left a reply on Saving Images To Separate Table • 2 months ago

@tykus after reading ur first solution and the explanation..it made sense ..THANKS

-- ill be using the second solution you gave tho ..

mac03733 left a reply on Saving Images To Separate Table • 2 months ago

@ tykus after looking at ur first answer and reading the explanation ,it makes sense...THANKS

ill give it a try ..even tho i was hoping to stick to one syntax ..becouse iv been using this syntax through out the project ... $post= new Post; and with that solution id have to use DB::

mac03733 left a reply on Saving Images To Separate Table • 2 months ago

i am trying something like this ..

  public function addPost(Request $request)
        {
        
          $post= new Post;
          $post->title = $request->input('title');
          $post->body= $request->input('body');
         
          //i want to add the image to the images table with th post id as a foreign key
    if($request->hasFile('post_images')){
        foreach ($request->post_images as $image) {
            $image = new Image;
            $image->post_id = //-------------????
        }   
    }

       
          $post->save();
          
        

        }

mac03733 left a reply on Saving Images To Separate Table • 2 months ago

@lostdreamer_nl .. i am not trying to migrate the current data.

@tykus i am using eloquent

Edit Your Profile
Update

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